test_curswant.vim 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. " Tests for not changing curswant
  2. source check.vim
  3. source term_util.vim
  4. func Test_curswant()
  5. new
  6. call append(0, ['1234567890', '12345'])
  7. normal! ggf8j
  8. call assert_equal(7, winsaveview().curswant)
  9. let &tabstop=&tabstop
  10. call assert_equal(4, winsaveview().curswant)
  11. normal! ggf8j
  12. call assert_equal(7, winsaveview().curswant)
  13. let &timeoutlen=&timeoutlen
  14. call assert_equal(7, winsaveview().curswant)
  15. normal! ggf8j
  16. call assert_equal(7, winsaveview().curswant)
  17. let &ttimeoutlen=&ttimeoutlen
  18. call assert_equal(7, winsaveview().curswant)
  19. bw!
  20. endfunc
  21. func Test_normal_gm()
  22. CheckRunVimInTerminal
  23. let lines =<< trim END
  24. call setline(1, repeat([" abcd\tefgh\tij"], 10))
  25. call cursor(1, 1)
  26. END
  27. call writefile(lines, 'XtestCurswant', 'D')
  28. let buf = RunVimInTerminal('-S XtestCurswant', #{rows: 10})
  29. if has("folding")
  30. call term_sendkeys(buf, "jVjzf")
  31. " gm
  32. call term_sendkeys(buf, "gmk")
  33. call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
  34. call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
  35. " g0
  36. call term_sendkeys(buf, "jg0k")
  37. call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
  38. call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
  39. " g^
  40. call term_sendkeys(buf, "jg^k")
  41. call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
  42. call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
  43. endif
  44. call term_sendkeys(buf, ":call cursor(10, 1)\<cr>")
  45. " gm
  46. call term_sendkeys(buf, "gmk")
  47. call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
  48. call term_wait(buf)
  49. call WaitFor({-> term_getline(buf, 10) =~ '^18\s\+'})
  50. " g0
  51. call term_sendkeys(buf, "g0k")
  52. call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
  53. call WaitFor({-> term_getline(buf, 10) =~ '^1\s\+'})
  54. " g^
  55. call term_sendkeys(buf, "g^k")
  56. call term_sendkeys(buf, ":echo virtcol('.')\<cr>")
  57. call WaitFor({-> term_getline(buf, 10) =~ '^3\s\+'})
  58. " clean up
  59. call StopVimInTerminal(buf)
  60. wincmd p
  61. wincmd c
  62. endfunc
  63. " vim: shiftwidth=2 sts=2 expandtab