textobjects_spec.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. local n = require('test.functional.testnvim')()
  2. local call = n.call
  3. local clear = n.clear
  4. local command = n.command
  5. local expect = n.expect
  6. local source = n.source
  7. describe('Text object', function()
  8. before_each(function()
  9. clear()
  10. command('set shada=')
  11. source([[
  12. function SelectionOut(data)
  13. new
  14. call setline(1, a:data)
  15. call setreg('"', '')
  16. normal! ggfrmavi)y
  17. $put =getreg('\"')
  18. call setreg('"', '')
  19. normal! `afbmavi)y
  20. $put =getreg('\"')
  21. call setreg('"', '')
  22. normal! `afgmavi)y
  23. $put =getreg('\"')
  24. endfunction
  25. ]])
  26. end)
  27. it('Test for vi) without cpo-M', function()
  28. command('set cpo-=M')
  29. call('SelectionOut', '(red \\(blue) green)')
  30. expect([[
  31. (red \(blue) green)
  32. red \(blue
  33. red \(blue
  34. ]])
  35. end)
  36. it('Test for vi) with cpo-M #1', function()
  37. command('set cpo+=M')
  38. call('SelectionOut', '(red \\(blue) green)')
  39. expect([[
  40. (red \(blue) green)
  41. red \(blue) green
  42. blue
  43. red \(blue) green]])
  44. end)
  45. it('Test for vi) with cpo-M #2', function()
  46. command('set cpo+=M')
  47. call('SelectionOut', '(red (blue\\) green)')
  48. expect([[
  49. (red (blue\) green)
  50. red (blue\) green
  51. blue\
  52. red (blue\) green]])
  53. end)
  54. end)