keeppos.vimspec 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. scriptencoding utf-8
  2. Describe basic_asterisk
  3. Before all
  4. let lines = [
  5. \ '1.asterisk 2.asterisk 3.asterisk'
  6. \ , '4.Asterisk 5.AsteRisK 6.Asterisk'
  7. \ , ''
  8. \ , '7.アスタリスク 8.アスタリスクです 9.アスタリスク?'
  9. \ ]
  10. call g:Add_lines(lines)
  11. let g:asterisk#keeppos = 1
  12. End
  13. Before each
  14. call cursor([1, 1])
  15. normal! 2l
  16. End
  17. After all
  18. :1,$ delete
  19. let g:asterisk#keeppos = 0
  20. End
  21. Describe keeppos *
  22. It search forward with \<\> keeping cursor position
  23. normal! 3l
  24. normal *
  25. Assert Equals(histget('/', -1), '\<asterisk\>/s+3')
  26. End
  27. It keep cursor position without offset
  28. normal *
  29. Assert Equals(histget('/', -1), '\<asterisk\>')
  30. End
  31. It doesn't keep cursor position if the char under cursor is not keyword
  32. normal 1h
  33. normal *
  34. Assert Equals(histget('/', -1), '\<asterisk\>')
  35. End
  36. It handles multibyte
  37. normal! 3j2l
  38. normal *
  39. Assert Equals(histget('/', -1), '\<アスタリスク\>/s+2')
  40. End
  41. End
  42. Describe keeppos g*
  43. It search forward keeping cursor position
  44. normal! 3l
  45. normal g*
  46. Assert Equals(histget('/', -1), 'asterisk/s+3')
  47. End
  48. It keep cursor position without offset
  49. normal g*
  50. Assert Equals(histget('/', -1), 'asterisk')
  51. End
  52. It doesn't keep cursor position if the char under cursor is not keyword
  53. normal 1h
  54. normal g*
  55. Assert Equals(histget('/', -1), 'asterisk')
  56. End
  57. End
  58. Describe keeppos #
  59. It search backward with \<\> keeping cursor position
  60. normal! 3l
  61. normal #
  62. Assert Equals(histget('/', -1), '\<asterisk\>?s+3')
  63. End
  64. It search backward and correct count at the end of word
  65. normal! $
  66. normal #
  67. Assert Equals(histget('/', -1), '\<asterisk\>?s+7')
  68. normal! 9h
  69. Assert Equals(g:Get_pos_char(), '2')
  70. End
  71. It keep cursor position without offset
  72. normal #
  73. Assert Equals(histget('/', -1), '\<asterisk\>')
  74. End
  75. It doesn't keep cursor position if the char under cursor is not keyword
  76. normal 1h
  77. normal #
  78. Assert Equals(histget('/', -1), '\<asterisk\>')
  79. End
  80. End
  81. Describe keeppos g#
  82. It search forward keeping cursor position
  83. normal! 3l
  84. normal g#
  85. Assert Equals(histget('/', -1), 'asterisk?s+3')
  86. End
  87. It keep cursor position without offset
  88. normal g#
  89. Assert Equals(histget('/', -1), 'asterisk')
  90. End
  91. It doesn't keep cursor position if the char under cursor is not keyword
  92. normal 1h
  93. normal g#
  94. Assert Equals(histget('/', -1), 'asterisk')
  95. End
  96. End
  97. End