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