undojoin_spec.lua 911 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local eq = t.eq
  4. local clear = n.clear
  5. local insert = n.insert
  6. local feed = n.feed
  7. local expect = n.expect
  8. local feed_command = n.feed_command
  9. local exc_exec = n.exc_exec
  10. describe(':undojoin command', function()
  11. before_each(function()
  12. clear()
  13. insert([[
  14. Line of text 1
  15. Line of text 2]])
  16. feed_command('goto 1')
  17. end)
  18. it('joins changes in a buffer', function()
  19. feed_command('undojoin | delete')
  20. expect([[
  21. Line of text 2]])
  22. feed('u')
  23. expect([[
  24. ]])
  25. end)
  26. it('does not corrupt undolist when connected with redo', function()
  27. feed('ixx<esc>')
  28. feed_command('undojoin | redo')
  29. expect([[
  30. xxLine of text 1
  31. Line of text 2]])
  32. end)
  33. it('does not raise an error when called twice', function()
  34. local ret = exc_exec('undojoin | undojoin')
  35. eq(0, ret)
  36. end)
  37. end)