019_smarttab_expandtab_spec.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. -- Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set.
  2. -- Also test that dv_ works correctly
  3. local n = require('test.functional.testnvim')()
  4. local feed, insert = n.feed, n.insert
  5. local clear, feed_command, expect = n.clear, n.feed_command, n.expect
  6. describe([[performing "r<Tab>" with 'smarttab' and 'expandtab' set/not set, and "dv_"]], function()
  7. setup(clear)
  8. -- luacheck: ignore 621 (Indentation)
  9. it('is working', function()
  10. insert([[
  11. start text
  12. some test text
  13. test text
  14. other test text
  15. a cde
  16. f ghi
  17. test text
  18. Second line beginning with whitespace]])
  19. feed_command('set smarttab expandtab ts=8 sw=4')
  20. -- Make sure that backspace works, no matter what termcap is used.
  21. feed_command('set t_kD=x7f t_kb=x08')
  22. feed_command('/some')
  23. feed('r ')
  24. feed_command('set noexpandtab')
  25. feed_command('/other')
  26. feed('r <cr>')
  27. -- Test replacing with Tabs and then backspacing to undo it.
  28. feed('0wR <bs><bs><bs><esc><cr>')
  29. -- Test replacing with Tabs.
  30. feed('0wR <esc><cr>')
  31. -- Test that copyindent works with expandtab set.
  32. feed_command('set expandtab smartindent copyindent ts=8 sw=8 sts=8')
  33. feed('o{<cr>x<esc>')
  34. feed_command('set nosol')
  35. feed_command('/Second line/')
  36. -- Test "dv_"
  37. feed('fwdv_')
  38. -- Assert buffer contents.
  39. expect([[
  40. start text
  41. ome test text
  42. test text
  43. ther test text
  44. a cde
  45. hi
  46. test text
  47. {
  48. x
  49. with whitespace]])
  50. end)
  51. end)