robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.3 KiB50 linesraw
1-- Test for visual mode not being reset causing E315 error.
2
3local n = require('test.functional.testnvim')()
4local t = require('test.testutil')
5
6local describe, it, setup = t.describe, t.it, t.setup
7local feed, source = n.feed, n.source
8local clear, expect = n.clear, n.expect
9
10describe('E315 error', function()
11  setup(clear)
12
13  it('is working', function()
14    -- At this point there is no visual selection because :call reset it.
15    -- Let's restore the selection:
16    source([[
17      let g:msg="Everything's fine."
18      function! TriggerTheProblem()
19          normal gv
20          '<,'>del _
21          try
22              exe "normal \<Esc>"
23          catch /^Vim\%((\a\+)\)\=:E315/
24              echom 'Snap! E315 error!'
25              let g:msg='Snap! E315 error!'
26          endtry
27      endfunction
28      enew
29      enew
30      setl buftype=nofile
31      call append(line('$'), 'Delete this line.')
32    ]])
33
34    -- NOTE: this has to be done by a call to a function because executing
35    -- :del the ex-way will require the colon operator which resets the
36    -- visual mode thus preventing the problem:
37    feed('GV:call TriggerTheProblem()<cr>')
38
39    source([[
40      %del _
41      call append(line('$'), g:msg)
42      brewind
43    ]])
44
45    -- Assert buffer contents.
46    expect([[
47
48      Everything's fine.]])
49  end)
50end)