103_visual_mode_reset_spec.lua 1.2 KB

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