robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
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 () 11setup ( clear ) 12 13it ( 'is working' , function () 14-- At this point there is no visual selection because :call reset it. 15-- Let's restore the selection: 16source ( [[ 17let g:msg="Everything's fine." 18function! TriggerTheProblem() 19normal gv 20'<,'>del _ 21try 22exe "normal \<Esc>" 23catch /^Vim\%((\a\+)\)\=:E315/ 24echom 'Snap! E315 error!' 25let g:msg='Snap! E315 error!' 26endtry 27endfunction 28enew 29enew 30setl buftype=nofile 31call 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: 37feed ( 'GV:call TriggerTheProblem()<cr>' ) 38 39source ( [[ 40%del _ 41call append(line('$'), g:msg) 42brewind 43]] ) 44 45-- Assert buffer contents. 46expect ( [[ 47 48Everything's fine.]] ) 49end ) 50end )