pastetoggle_spec.lua 943 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local clear = helpers.clear
  3. local feed = helpers.feed
  4. local command = helpers.command
  5. local eq = helpers.eq
  6. local eval = helpers.eval
  7. local sleep = helpers.sleep
  8. local expect = helpers.expect
  9. describe("'pastetoggle' option", function()
  10. before_each(function()
  11. clear()
  12. command('set nopaste')
  13. end)
  14. it("toggles 'paste'", function()
  15. command('set pastetoggle=a')
  16. eq(0, eval('&paste'))
  17. feed('a')
  18. -- Need another key so that the vgetorpeek() function returns.
  19. feed('j')
  20. eq(1, eval('&paste'))
  21. end)
  22. it('does not wait for timeout', function()
  23. command('set pastetoggle=abc')
  24. command('set ttimeoutlen=9999999')
  25. eq(0, eval('&paste'))
  26. -- n.b. need <esc> to return from vgetorpeek()
  27. feed('abc<esc>')
  28. eq(1, eval('&paste'))
  29. feed('ab')
  30. sleep(10)
  31. feed('c<esc>')
  32. expect('bc')
  33. eq(1, eval('&paste'))
  34. end)
  35. end)