robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.3 KiB60 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3
4local describe, it, before_each = t.describe, t.it, t.before_each
5local clear = n.clear
6local eq = t.eq
7local exec = n.exec
8local feed = n.feed
9local api = n.api
10
11before_each(clear)
12
13describe('SafeState autocommand', function()
14  local function create_autocmd()
15    exec([[
16      let g:safe = 0
17      autocmd SafeState * ++once let g:safe += 1
18    ]])
19  end
20
21  it('with pending operator', function()
22    feed('d')
23    create_autocmd()
24    eq(0, api.nvim_get_var('safe'))
25    feed('d')
26    eq(1, api.nvim_get_var('safe'))
27  end)
28
29  it('with specified register', function()
30    feed('"r')
31    create_autocmd()
32    eq(0, api.nvim_get_var('safe'))
33    feed('x')
34    eq(1, api.nvim_get_var('safe'))
35  end)
36
37  it('with i_CTRL-O', function()
38    feed('i<C-O>')
39    create_autocmd()
40    eq(0, api.nvim_get_var('safe'))
41    feed('x')
42    eq(1, api.nvim_get_var('safe'))
43  end)
44
45  it('with Insert mode completion', function()
46    feed('i<C-X><C-V>')
47    create_autocmd()
48    eq(0, api.nvim_get_var('safe'))
49    feed('<C-X><C-Z>')
50    eq(1, api.nvim_get_var('safe'))
51  end)
52
53  it('with Cmdline completion', function()
54    feed(':<Tab>')
55    create_autocmd()
56    eq(0, api.nvim_get_var('safe'))
57    feed('<C-E>')
58    eq(1, api.nvim_get_var('safe'))
59  end)
60end)