signs_spec.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. screen:add_extra_attr_ids({
  23. [100] = { foreground = Screen.colors.Blue4, background = Screen.colors.Yellow },
  24. })
  25. exec([[
  26. call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
  27. call cursor(2,1)
  28. sign define s1 texthl=Search text==>
  29. sign define s2 linehl=Pmenu
  30. redraw
  31. sign place 10 line=2 name=s1
  32. ]])
  33. screen:expect([[
  34. {7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  35. {7: }xx |
  36. {100:=>}^mmmm |
  37. {7: }yyyy |
  38. {1:~ }|
  39. |
  40. ]])
  41. -- Change the sign text
  42. command('sign define s1 text=-)')
  43. screen:expect([[
  44. {7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  45. {7: }xx |
  46. {100:-)}^mmmm |
  47. {7: }yyyy |
  48. {1:~ }|
  49. |
  50. ]])
  51. -- Also place a line HL sign
  52. command('sign place 11 line=2 name=s2')
  53. screen:expect([[
  54. {7: }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  55. {7: }xx |
  56. {100:-)}{4:^mmmm }|
  57. {7: }yyyy |
  58. {1:~ }|
  59. |
  60. ]])
  61. -- update cursor position calculation
  62. feed('lh')
  63. command('sign unplace 11')
  64. command('sign unplace 10')
  65. screen:expect([[
  66. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  67. ^mmmm |
  68. yyyy |
  69. {1:~ }|*2
  70. |
  71. ]])
  72. end)
  73. end)