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