signs_spec.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. -- Tests for signs
  2. local n = require('test.functional.testnvim')()
  3. local Screen = require('test.functional.ui.screen')
  4. local clear, command, exec, expect, feed = n.clear, n.command, n.exec, n.expect, n.feed
  5. describe('signs', function()
  6. before_each(clear)
  7. it('are working', function()
  8. command('sign define JumpSign text=x')
  9. command([[exe 'sign place 42 line=2 name=JumpSign buffer=' . bufnr('')]])
  10. -- Split the window to the bottom to verify :sign-jump will stay in the current
  11. -- window if the buffer is displayed there.
  12. command('bot split')
  13. command([[exe 'sign jump 42 buffer=' . bufnr('')]])
  14. command([[call append(line('$'), winnr())]])
  15. -- Assert buffer contents.
  16. expect([[
  17. 2]])
  18. end)
  19. -- oldtest: Test_sign_cursor_position()
  20. it('are drawn correctly', function()
  21. local screen = Screen.new(75, 6)
  22. exec([[
  23. call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
  24. call cursor(2,1)
  25. sign define s1 texthl=Search text==>
  26. sign define s2 linehl=Pmenu
  27. redraw
  28. sign place 10 line=2 name=s1
  29. ]])
  30. screen:expect([[
  31. {7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  32. {7: }xx |
  33. {10:=>}^mmmm |
  34. {7: }yyyy |
  35. {1:~ }|
  36. |
  37. ]])
  38. -- Change the sign text
  39. command('sign define s1 text=-)')
  40. screen:expect([[
  41. {7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  42. {7: }xx |
  43. {10:-)}^mmmm |
  44. {7: }yyyy |
  45. {1:~ }|
  46. |
  47. ]])
  48. -- Also place a line HL sign
  49. command('sign place 11 line=2 name=s2')
  50. screen:expect([[
  51. {7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  52. {7: }xx |
  53. {10:-)}{4:^mmmm }|
  54. {7: }yyyy |
  55. {1:~ }|
  56. |
  57. ]])
  58. -- update cursor position calculation
  59. feed('lh')
  60. command('sign unplace 11')
  61. command('sign unplace 10')
  62. screen:expect([[
  63. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  64. ^mmmm |
  65. yyyy |
  66. {1:~ }|*2
  67. |
  68. ]])
  69. end)
  70. end)