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/autocmd/safestate_spec.lua
local t = require('test.testutil')
local n = require('test.functional.testnvim')()

local clear = n.clear
local eq = t.eq
local exec = n.exec
local feed = n.feed
local api = n.api

before_each(clear)

describe('SafeState autocommand', function()
  local function create_autocmd()
    exec([[
      let g:safe = 0
      autocmd SafeState * ++once let g:safe += 1
    ]])
  end

  it('with pending operator', function()
    feed('d')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('d')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with specified register', function()
    feed('"r')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('x')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with i_CTRL-O', function()
    feed('i<C-O>')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('x')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with Insert mode completion', function()
    feed('i<C-X><C-V>')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('<C-X><C-Z>')
    eq(1, api.nvim_get_var('safe'))
  end)

  it('with Cmdline completion', function()
    feed(':<Tab>')
    create_autocmd()
    eq(0, api.nvim_get_var('safe'))
    feed('<C-E>')
    eq(1, api.nvim_get_var('safe'))
  end)
end)