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