HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/ubuntu/neovim/test/functional/ex_cmds/excmd_spec.lua
local t = require('test.testutil')
local n = require('test.functional.testnvim')()

local command = n.command
local eq = t.eq
local clear = n.clear
local fn = n.fn
local pcall_err = t.pcall_err
local assert_alive = n.assert_alive

describe('Ex cmds', function()
  before_each(function()
    clear()
  end)

  local function check_excmd_err(cmd, err)
    eq(err .. ': ' .. cmd, pcall_err(command, cmd))
  end

  it('handle integer overflow from user-input #5555', function()
    command(':9999999999999999999999999999999999999999')
    command(':later 9999999999999999999999999999999999999999')
    command(':echo expand("#<9999999999999999999999999999999999999999")')
    command(':lockvar 9999999999999999999999999999999999999999')
    command(
      ':winsize 9999999999999999999999999999999999999999 9999999999999999999999999999999999999999'
    )
    check_excmd_err(
      ':tabnext 9999999999999999999999999999999999999999',
      'Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999'
    )
    eq(
      'Vim(Next):E163: There is only one file to edit',
      pcall_err(command, ':N 9999999999999999999999999999999999999999')
    )
    check_excmd_err(
      ':bdelete 9999999999999999999999999999999999999999',
      'Vim(bdelete):E516: No buffers were deleted'
    )
    eq(
      'Vim(menu):E329: No menu "9999999999999999999999999999999999999999"',
      pcall_err(command, ':menu 9999999999999999999999999999999999999999')
    )
    assert_alive()
  end)

  it('listing long user command does not crash', function()
    command('execute "command" repeat("T", 255) ":"')
    command('command')
  end)

  it(':def is an unknown command #23149', function()
    eq('Vim:E492: Not an editor command: def', pcall_err(command, 'def'))
    eq(1, fn.exists(':d'))
    eq('delete', fn.fullcommand('d'))
    eq(1, fn.exists(':de'))
    eq('delete', fn.fullcommand('de'))
    eq(0, fn.exists(':def'))
    eq('', fn.fullcommand('def'))
    eq(1, fn.exists(':defe'))
    eq('defer', fn.fullcommand('defe'))
    eq(2, fn.exists(':defer'))
    eq('defer', fn.fullcommand('defer'))
  end)
end)