neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

safestate_spec.lua (1267B)


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