088_conceal_tabs_spec.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. -- Tests for correct display (cursor column position) with +conceal and
  2. -- tabulators.
  3. local helpers = require('test.functional.helpers')(after_each)
  4. local feed, insert, clear, feed_command =
  5. helpers.feed, helpers.insert, helpers.clear, helpers.feed_command
  6. local expect_pos = function(row, col)
  7. return helpers.eq({row, col}, helpers.eval('[screenrow(), screencol()]'))
  8. end
  9. describe('cursor and column position with conceal and tabulators', function()
  10. setup(clear)
  11. -- luacheck: ignore 621 (Indentation)
  12. it('are working', function()
  13. insert([[
  14. start:
  15. .concealed. text
  16. |concealed| text
  17. .concealed. text
  18. |concealed| text
  19. .a. .b. .c. .d.
  20. |a| |b| |c| |d|]])
  21. -- Conceal settings.
  22. feed_command('set conceallevel=2')
  23. feed_command('set concealcursor=nc')
  24. feed_command('syntax match test /|/ conceal')
  25. -- Start test.
  26. feed_command('/^start:')
  27. feed('ztj')
  28. expect_pos(2, 1)
  29. -- We should end up in the same column when running these commands on the
  30. -- two lines.
  31. feed('ft')
  32. expect_pos(2, 17)
  33. feed('$')
  34. expect_pos(2, 20)
  35. feed('0j')
  36. expect_pos(3, 1)
  37. feed('ft')
  38. expect_pos(3, 17)
  39. feed('$')
  40. expect_pos(3, 20)
  41. feed('j0j')
  42. expect_pos(5, 8)
  43. -- Same for next test block.
  44. feed('ft')
  45. expect_pos(5, 25)
  46. feed('$')
  47. expect_pos(5, 28)
  48. feed('0j')
  49. expect_pos(6, 8)
  50. feed('ft')
  51. expect_pos(6, 25)
  52. feed('$')
  53. expect_pos(6, 28)
  54. feed('0j0j')
  55. expect_pos(8, 1)
  56. -- And check W with multiple tabs and conceals in a line.
  57. feed('W')
  58. expect_pos(8, 9)
  59. feed('W')
  60. expect_pos(8, 17)
  61. feed('W')
  62. expect_pos(8, 25)
  63. feed('$')
  64. expect_pos(8, 27)
  65. feed('0j')
  66. expect_pos(9, 1)
  67. feed('W')
  68. expect_pos(9, 9)
  69. feed('W')
  70. expect_pos(9, 17)
  71. feed('W')
  72. expect_pos(9, 25)
  73. feed('$')
  74. expect_pos(9, 26)
  75. feed_command('set lbr')
  76. feed('$')
  77. expect_pos(9, 26)
  78. feed_command('set list listchars=tab:>-')
  79. feed('0')
  80. expect_pos(9, 1)
  81. feed('W')
  82. expect_pos(9, 9)
  83. feed('W')
  84. expect_pos(9, 17)
  85. feed('W')
  86. expect_pos(9, 25)
  87. feed('$')
  88. expect_pos(9, 26)
  89. end)
  90. end)