Bram Moolenaar | d07c6e1 | 2013-11-21 14:21:40 +0100 | [diff] [blame] | 1 | Test for visual mode not being reset causing E315 error. |
| 2 | STARTTEST |
| 3 | :so small.vim |
| 4 | :enew |
| 5 | :let g:msg="Everything's fine." |
| 6 | :function! TriggerTheProblem() |
| 7 | : " At this point there is no visual selection because :call reset it. |
| 8 | : " Let's restore the selection: |
| 9 | : normal gv |
| 10 | : '<,'>del _ |
| 11 | : try |
| 12 | : exe "normal \<Esc>" |
| 13 | : catch /^Vim\%((\a\+)\)\=:E315/ |
| 14 | : echom 'Snap! E315 error!' |
| 15 | : let g:msg='Snap! E315 error!' |
| 16 | : endtry |
| 17 | :endfunction |
| 18 | :enew |
| 19 | :setl buftype=nofile |
| 20 | :call append(line('$'), 'Delete this line.') |
| 21 | :" |
| 22 | :" |
| 23 | :" NOTE: this has to be done by a call to a function because executing :del the |
| 24 | :" ex-way will require the colon operator which resets the visual mode thus |
| 25 | :" preventing the problem: |
| 26 | :" |
| 27 | GV:call TriggerTheProblem() |
| 28 | :%del _ |
| 29 | :call append(line('$'), g:msg) |
| 30 | :w! test.out |
| 31 | :brewind |
| 32 | ENDTEST |
| 33 | |
| 34 | STARTTEST |
| 35 | :qa! |
| 36 | ENDTEST |
| 37 | |