Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 1 | " Tests for cursor() and other functions that get/set the cursor position |
Bram Moolenaar | 5a46a58 | 2016-01-15 15:56:58 +0100 | [diff] [blame] | 2 | |
| 3 | func Test_wrong_arguments() |
Bram Moolenaar | 3717540 | 2017-03-18 20:18:45 +0100 | [diff] [blame] | 4 | call assert_fails('call cursor(1. 3)', 'E474:') |
Bram Moolenaar | 92b83cc | 2020-04-25 15:24:44 +0200 | [diff] [blame] | 5 | call assert_fails('call cursor(test_null_list())', 'E474:') |
Bram Moolenaar | 5a46a58 | 2016-01-15 15:56:58 +0100 | [diff] [blame] | 6 | endfunc |
| 7 | |
| 8 | func Test_move_cursor() |
| 9 | new |
| 10 | call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) |
| 11 | |
| 12 | call cursor([1, 1, 0, 1]) |
| 13 | call assert_equal([1, 1, 0, 1], getcurpos()[1:]) |
| 14 | call cursor([4, 3, 0, 3]) |
| 15 | call assert_equal([4, 3, 0, 3], getcurpos()[1:]) |
| 16 | |
| 17 | call cursor(2, 2) |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 18 | call assert_equal([2, 2, 0, 2], getcurpos()[1:]) |
Bram Moolenaar | 5a46a58 | 2016-01-15 15:56:58 +0100 | [diff] [blame] | 19 | " line number zero keeps the line number |
| 20 | call cursor(0, 1) |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 21 | call assert_equal([2, 1, 0, 1], getcurpos()[1:]) |
Bram Moolenaar | 5a46a58 | 2016-01-15 15:56:58 +0100 | [diff] [blame] | 22 | " col number zero keeps the column |
| 23 | call cursor(3, 0) |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 24 | call assert_equal([3, 1, 0, 1], getcurpos()[1:]) |
Bram Moolenaar | 5a46a58 | 2016-01-15 15:56:58 +0100 | [diff] [blame] | 25 | " below last line goes to last line |
Bram Moolenaar | 1a3a891 | 2019-08-23 22:31:37 +0200 | [diff] [blame] | 26 | eval [9, 1]->cursor() |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 27 | call assert_equal([4, 1, 0, 1], getcurpos()[1:]) |
Bram Moolenaar | 9ebcf23 | 2021-01-16 16:52:49 +0100 | [diff] [blame] | 28 | " pass string arguments |
| 29 | call cursor('3', '3') |
| 30 | call assert_equal([3, 3, 0, 3], getcurpos()[1:]) |
Bram Moolenaar | 5a46a58 | 2016-01-15 15:56:58 +0100 | [diff] [blame] | 31 | |
Bram Moolenaar | 17aca70 | 2019-05-16 22:24:55 +0200 | [diff] [blame] | 32 | call setline(1, ["\<TAB>"]) |
| 33 | call cursor(1, 1, 1) |
| 34 | call assert_equal([1, 1, 1], getcurpos()[1:3]) |
| 35 | |
Bram Moolenaar | 9a96337 | 2020-12-21 21:58:46 +0100 | [diff] [blame] | 36 | call assert_fails('call cursor(-1, -1)', 'E475:') |
Bram Moolenaar | 17aca70 | 2019-05-16 22:24:55 +0200 | [diff] [blame] | 37 | |
Bram Moolenaar | 5a46a58 | 2016-01-15 15:56:58 +0100 | [diff] [blame] | 38 | quit! |
| 39 | endfunc |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 40 | |
| 41 | " Very short version of what matchparen does. |
| 42 | function s:Highlight_Matching_Pair() |
| 43 | let save_cursor = getcurpos() |
Bram Moolenaar | aad222c | 2019-09-06 22:46:09 +0200 | [diff] [blame] | 44 | eval save_cursor->setpos('.') |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 45 | endfunc |
| 46 | |
| 47 | func Test_curswant_with_autocommand() |
| 48 | new |
| 49 | call setline(1, ['func()', '{', '}', '----']) |
| 50 | autocmd! CursorMovedI * call s:Highlight_Matching_Pair() |
Bram Moolenaar | eb992cb | 2017-03-09 18:20:16 +0100 | [diff] [blame] | 51 | call test_override("char_avail", 1) |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 52 | exe "normal! 3Ga\<Down>X\<Esc>" |
Bram Moolenaar | eb992cb | 2017-03-09 18:20:16 +0100 | [diff] [blame] | 53 | call test_override("char_avail", 0) |
Bram Moolenaar | 2ab375e | 2016-02-10 22:23:06 +0100 | [diff] [blame] | 54 | call assert_equal('-X---', getline(4)) |
| 55 | autocmd! CursorMovedI * |
| 56 | quit! |
| 57 | endfunc |
| 58 | |
Bram Moolenaar | 177ab9e | 2019-01-15 21:12:57 +0100 | [diff] [blame] | 59 | " Tests for behavior of curswant with cursorcolumn/line |
| 60 | func Test_curswant_with_cursorcolumn() |
| 61 | new |
| 62 | call setline(1, ['01234567', '']) |
| 63 | exe "normal! ggf6j" |
| 64 | call assert_equal(6, winsaveview().curswant) |
| 65 | set cursorcolumn |
| 66 | call assert_equal(6, winsaveview().curswant) |
| 67 | quit! |
| 68 | endfunc |
| 69 | |
| 70 | func Test_curswant_with_cursorline() |
| 71 | new |
| 72 | call setline(1, ['01234567', '']) |
| 73 | exe "normal! ggf6j" |
| 74 | call assert_equal(6, winsaveview().curswant) |
| 75 | set cursorline |
| 76 | call assert_equal(6, winsaveview().curswant) |
| 77 | quit! |
| 78 | endfunc |
Bram Moolenaar | b3d17a2 | 2019-07-07 18:28:14 +0200 | [diff] [blame] | 79 | |
| 80 | func Test_screenpos() |
| 81 | rightbelow new |
| 82 | rightbelow 20vsplit |
| 83 | call setline(1, ["\tsome text", "long wrapping line here", "next line"]) |
| 84 | redraw |
| 85 | let winid = win_getid() |
| 86 | let [winrow, wincol] = win_screenpos(winid) |
| 87 | call assert_equal({'row': winrow, |
| 88 | \ 'col': wincol + 0, |
| 89 | \ 'curscol': wincol + 7, |
Bram Moolenaar | f92e58c | 2019-09-08 21:51:41 +0200 | [diff] [blame] | 90 | \ 'endcol': wincol + 7}, winid->screenpos(1, 1)) |
Bram Moolenaar | b3d17a2 | 2019-07-07 18:28:14 +0200 | [diff] [blame] | 91 | call assert_equal({'row': winrow, |
| 92 | \ 'col': wincol + 13, |
| 93 | \ 'curscol': wincol + 13, |
Bram Moolenaar | 196b466 | 2019-09-06 21:34:30 +0200 | [diff] [blame] | 94 | \ 'endcol': wincol + 13}, winid->screenpos(1, 7)) |
Bram Moolenaar | b3d17a2 | 2019-07-07 18:28:14 +0200 | [diff] [blame] | 95 | call assert_equal({'row': winrow + 2, |
| 96 | \ 'col': wincol + 1, |
| 97 | \ 'curscol': wincol + 1, |
| 98 | \ 'endcol': wincol + 1}, screenpos(winid, 2, 22)) |
| 99 | setlocal number |
| 100 | call assert_equal({'row': winrow + 3, |
| 101 | \ 'col': wincol + 9, |
| 102 | \ 'curscol': wincol + 9, |
| 103 | \ 'endcol': wincol + 9}, screenpos(winid, 2, 22)) |
| 104 | close |
Bram Moolenaar | bdd2c29 | 2020-06-22 21:34:30 +0200 | [diff] [blame] | 105 | call assert_equal({}, screenpos(999, 1, 1)) |
Bram Moolenaar | b3d17a2 | 2019-07-07 18:28:14 +0200 | [diff] [blame] | 106 | bwipe! |
Bram Moolenaar | 8dd46e7 | 2020-12-17 21:35:29 +0100 | [diff] [blame] | 107 | |
| 108 | call assert_equal({'col': 1, 'row': 1, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) |
| 109 | nmenu WinBar.TEST : |
| 110 | call assert_equal({'col': 1, 'row': 2, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) |
| 111 | nunmenu WinBar.TEST |
Bram Moolenaar | b3d17a2 | 2019-07-07 18:28:14 +0200 | [diff] [blame] | 112 | endfunc |
Bram Moolenaar | 38ba4dc | 2019-10-27 21:39:09 +0100 | [diff] [blame] | 113 | |
| 114 | func Test_screenpos_number() |
| 115 | rightbelow new |
| 116 | rightbelow 73vsplit |
| 117 | call setline (1, repeat('x', 66)) |
| 118 | setlocal number |
| 119 | redraw |
| 120 | let winid = win_getid() |
| 121 | let [winrow, wincol] = win_screenpos(winid) |
| 122 | let pos = screenpos(winid, 1, 66) |
| 123 | call assert_equal(winrow, pos.row) |
| 124 | call assert_equal(wincol + 66 + 3, pos.col) |
| 125 | close |
| 126 | bwipe! |
| 127 | endfunc |
Bram Moolenaar | 08f4157 | 2020-04-20 16:50:00 +0200 | [diff] [blame] | 128 | |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 129 | " Save the visual start character position |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 130 | func SaveVisualStartCharPos() |
| 131 | call add(g:VisualStartPos, getcharpos('v')) |
| 132 | return '' |
| 133 | endfunc |
| 134 | |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 135 | " Save the current cursor character position in insert mode |
| 136 | func SaveInsertCurrentCharPos() |
| 137 | call add(g:InsertCurrentPos, getcharpos('.')) |
| 138 | return '' |
| 139 | endfunc |
| 140 | |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 141 | " Test for the getcharpos() function |
| 142 | func Test_getcharpos() |
| 143 | call assert_fails('call getcharpos({})', 'E731:') |
| 144 | call assert_equal([0, 0, 0, 0], getcharpos(0)) |
| 145 | new |
| 146 | call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
| 147 | |
| 148 | " Test for '.' and '$' |
| 149 | normal 1G |
| 150 | call assert_equal([0, 1, 1, 0], getcharpos('.')) |
| 151 | call assert_equal([0, 4, 1, 0], getcharpos('$')) |
| 152 | normal 2G6l |
| 153 | call assert_equal([0, 2, 7, 0], getcharpos('.')) |
| 154 | normal 3G$ |
| 155 | call assert_equal([0, 3, 1, 0], getcharpos('.')) |
| 156 | normal 4G$ |
| 157 | call assert_equal([0, 4, 9, 0], getcharpos('.')) |
| 158 | |
| 159 | " Test for a mark |
| 160 | normal 2G7lmmgg |
| 161 | call assert_equal([0, 2, 8, 0], getcharpos("'m")) |
| 162 | delmarks m |
| 163 | call assert_equal([0, 0, 0, 0], getcharpos("'m")) |
| 164 | |
| 165 | " Test for the visual start column |
| 166 | vnoremap <expr> <F3> SaveVisualStartCharPos() |
| 167 | let g:VisualStartPos = [] |
| 168 | exe "normal 2G6lv$\<F3>ohh\<F3>o\<F3>" |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 169 | call assert_equal([[0, 2, 7, 0], [0, 2, 10, 0], [0, 2, 5, 0]], g:VisualStartPos) |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 170 | call assert_equal([0, 2, 9, 0], getcharpos('v')) |
| 171 | let g:VisualStartPos = [] |
| 172 | exe "normal 3Gv$\<F3>o\<F3>" |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 173 | call assert_equal([[0, 3, 1, 0], [0, 3, 2, 0]], g:VisualStartPos) |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 174 | let g:VisualStartPos = [] |
| 175 | exe "normal 1Gv$\<F3>o\<F3>" |
| 176 | call assert_equal([[0, 1, 1, 0], [0, 1, 1, 0]], g:VisualStartPos) |
| 177 | vunmap <F3> |
| 178 | |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 179 | " Test for getting the position in insert mode with the cursor after the |
| 180 | " last character in a line |
| 181 | inoremap <expr> <F3> SaveInsertCurrentCharPos() |
| 182 | let g:InsertCurrentPos = [] |
| 183 | exe "normal 1GA\<F3>" |
| 184 | exe "normal 2GA\<F3>" |
| 185 | exe "normal 3GA\<F3>" |
| 186 | exe "normal 4GA\<F3>" |
| 187 | exe "normal 2G6li\<F3>" |
| 188 | call assert_equal([[0, 1, 1, 0], [0, 2, 10, 0], [0, 3, 2, 0], [0, 4, 10, 0], |
| 189 | \ [0, 2, 7, 0]], g:InsertCurrentPos) |
| 190 | iunmap <F3> |
| 191 | |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 192 | %bw! |
| 193 | endfunc |
| 194 | |
| 195 | " Test for the setcharpos() function |
| 196 | func Test_setcharpos() |
| 197 | call assert_equal(-1, setcharpos('.', test_null_list())) |
| 198 | new |
| 199 | call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
| 200 | call setcharpos('.', [0, 1, 1, 0]) |
| 201 | call assert_equal([1, 1], [line('.'), col('.')]) |
| 202 | call setcharpos('.', [0, 2, 7, 0]) |
| 203 | call assert_equal([2, 9], [line('.'), col('.')]) |
| 204 | call setcharpos('.', [0, 3, 4, 0]) |
| 205 | call assert_equal([3, 1], [line('.'), col('.')]) |
| 206 | call setcharpos('.', [0, 3, 1, 0]) |
| 207 | call assert_equal([3, 1], [line('.'), col('.')]) |
| 208 | call setcharpos('.', [0, 4, 0, 0]) |
| 209 | call assert_equal([4, 1], [line('.'), col('.')]) |
| 210 | call setcharpos('.', [0, 4, 20, 0]) |
| 211 | call assert_equal([4, 9], [line('.'), col('.')]) |
| 212 | |
| 213 | " Test for mark |
| 214 | delmarks m |
| 215 | call setcharpos("'m", [0, 2, 9, 0]) |
| 216 | normal `m |
| 217 | call assert_equal([2, 11], [line('.'), col('.')]) |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 218 | " unload the buffer and try to set the mark |
| 219 | let bnr = bufnr() |
| 220 | enew! |
| 221 | call assert_equal(-1, setcharpos("'m", [bnr, 2, 2, 0])) |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 222 | |
| 223 | %bw! |
| 224 | call assert_equal(-1, setcharpos('.', [10, 3, 1, 0])) |
| 225 | endfunc |
| 226 | |
| 227 | func SaveVisualStartCharCol() |
| 228 | call add(g:VisualStartCol, charcol('v')) |
| 229 | return '' |
| 230 | endfunc |
| 231 | |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 232 | func SaveInsertCurrentCharCol() |
| 233 | call add(g:InsertCurrentCol, charcol('.')) |
| 234 | return '' |
| 235 | endfunc |
| 236 | |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 237 | " Test for the charcol() function |
| 238 | func Test_charcol() |
| 239 | call assert_fails('call charcol({})', 'E731:') |
| 240 | call assert_equal(0, charcol(0)) |
| 241 | new |
| 242 | call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
| 243 | |
| 244 | " Test for '.' and '$' |
| 245 | normal 1G |
| 246 | call assert_equal(1, charcol('.')) |
| 247 | call assert_equal(1, charcol('$')) |
| 248 | normal 2G6l |
| 249 | call assert_equal(7, charcol('.')) |
| 250 | call assert_equal(10, charcol('$')) |
| 251 | normal 3G$ |
| 252 | call assert_equal(1, charcol('.')) |
| 253 | call assert_equal(2, charcol('$')) |
| 254 | normal 4G$ |
| 255 | call assert_equal(9, charcol('.')) |
| 256 | call assert_equal(10, charcol('$')) |
| 257 | |
| 258 | " Test for [lnum, '$'] |
| 259 | call assert_equal(1, charcol([1, '$'])) |
| 260 | call assert_equal(10, charcol([2, '$'])) |
| 261 | call assert_equal(2, charcol([3, '$'])) |
| 262 | call assert_equal(0, charcol([5, '$'])) |
| 263 | |
| 264 | " Test for a mark |
| 265 | normal 2G7lmmgg |
| 266 | call assert_equal(8, charcol("'m")) |
| 267 | delmarks m |
| 268 | call assert_equal(0, charcol("'m")) |
| 269 | |
| 270 | " Test for the visual start column |
| 271 | vnoremap <expr> <F3> SaveVisualStartCharCol() |
| 272 | let g:VisualStartCol = [] |
| 273 | exe "normal 2G6lv$\<F3>ohh\<F3>o\<F3>" |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 274 | call assert_equal([7, 10, 5], g:VisualStartCol) |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 275 | call assert_equal(9, charcol('v')) |
| 276 | let g:VisualStartCol = [] |
| 277 | exe "normal 3Gv$\<F3>o\<F3>" |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 278 | call assert_equal([1, 2], g:VisualStartCol) |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 279 | let g:VisualStartCol = [] |
| 280 | exe "normal 1Gv$\<F3>o\<F3>" |
| 281 | call assert_equal([1, 1], g:VisualStartCol) |
| 282 | vunmap <F3> |
| 283 | |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 284 | " Test for getting the column number in insert mode with the cursor after |
| 285 | " the last character in a line |
| 286 | inoremap <expr> <F3> SaveInsertCurrentCharCol() |
| 287 | let g:InsertCurrentCol = [] |
| 288 | exe "normal 1GA\<F3>" |
| 289 | exe "normal 2GA\<F3>" |
| 290 | exe "normal 3GA\<F3>" |
| 291 | exe "normal 4GA\<F3>" |
| 292 | exe "normal 2G6li\<F3>" |
| 293 | call assert_equal([1, 10, 2, 10, 7], g:InsertCurrentCol) |
| 294 | iunmap <F3> |
| 295 | |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 296 | %bw! |
| 297 | endfunc |
| 298 | |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 299 | func SaveInsertCursorCharPos() |
| 300 | call add(g:InsertCursorPos, getcursorcharpos('.')) |
| 301 | return '' |
| 302 | endfunc |
| 303 | |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 304 | " Test for getcursorcharpos() |
| 305 | func Test_getcursorcharpos() |
| 306 | call assert_equal(getcursorcharpos(), getcursorcharpos(0)) |
| 307 | call assert_equal([0, 0, 0, 0, 0], getcursorcharpos(-1)) |
| 308 | call assert_equal([0, 0, 0, 0, 0], getcursorcharpos(1999)) |
| 309 | |
| 310 | new |
| 311 | call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
| 312 | normal 1G9l |
| 313 | call assert_equal([0, 1, 1, 0, 1], getcursorcharpos()) |
| 314 | normal 2G9l |
| 315 | call assert_equal([0, 2, 9, 0, 14], getcursorcharpos()) |
| 316 | normal 3G9l |
| 317 | call assert_equal([0, 3, 1, 0, 1], getcursorcharpos()) |
| 318 | normal 4G9l |
| 319 | call assert_equal([0, 4, 9, 0, 9], getcursorcharpos()) |
| 320 | |
Bram Moolenaar | 9145846 | 2021-01-13 20:08:38 +0100 | [diff] [blame] | 321 | " Test for getting the cursor position in insert mode with the cursor after |
| 322 | " the last character in a line |
| 323 | inoremap <expr> <F3> SaveInsertCursorCharPos() |
| 324 | let g:InsertCursorPos = [] |
| 325 | exe "normal 1GA\<F3>" |
| 326 | exe "normal 2GA\<F3>" |
| 327 | exe "normal 3GA\<F3>" |
| 328 | exe "normal 4GA\<F3>" |
| 329 | exe "normal 2G6li\<F3>" |
| 330 | call assert_equal([[0, 1, 1, 0, 1], [0, 2, 10, 0, 15], [0, 3, 2, 0, 2], |
| 331 | \ [0, 4, 10, 0, 10], [0, 2, 7, 0, 12]], g:InsertCursorPos) |
| 332 | iunmap <F3> |
| 333 | |
Bram Moolenaar | 6f02b00 | 2021-01-10 20:22:54 +0100 | [diff] [blame] | 334 | let winid = win_getid() |
| 335 | normal 2G5l |
| 336 | wincmd w |
| 337 | call assert_equal([0, 2, 6, 0, 11], getcursorcharpos(winid)) |
| 338 | %bw! |
| 339 | endfunc |
| 340 | |
| 341 | " Test for setcursorcharpos() |
| 342 | func Test_setcursorcharpos() |
| 343 | call assert_fails('call setcursorcharpos(test_null_list())', 'E474:') |
| 344 | call assert_fails('call setcursorcharpos([1])', 'E474:') |
| 345 | call assert_fails('call setcursorcharpos([1, 1, 1, 1, 1])', 'E474:') |
| 346 | new |
| 347 | call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
| 348 | normal G |
| 349 | call setcursorcharpos([1, 1]) |
| 350 | call assert_equal([1, 1], [line('.'), col('.')]) |
| 351 | call setcursorcharpos([2, 7, 0]) |
| 352 | call assert_equal([2, 9], [line('.'), col('.')]) |
| 353 | call setcursorcharpos(3, 4) |
| 354 | call assert_equal([3, 1], [line('.'), col('.')]) |
| 355 | call setcursorcharpos([3, 1]) |
| 356 | call assert_equal([3, 1], [line('.'), col('.')]) |
| 357 | call setcursorcharpos([4, 0, 0, 0]) |
| 358 | call assert_equal([4, 1], [line('.'), col('.')]) |
| 359 | call setcursorcharpos([4, 20]) |
| 360 | call assert_equal([4, 9], [line('.'), col('.')]) |
| 361 | normal 1G |
| 362 | call setcursorcharpos([100, 100, 100, 100]) |
| 363 | call assert_equal([4, 9], [line('.'), col('.')]) |
| 364 | normal 1G |
| 365 | call setcursorcharpos('$', 1) |
| 366 | call assert_equal([4, 1], [line('.'), col('.')]) |
| 367 | |
| 368 | %bw! |
| 369 | endfunc |
| 370 | |
Bram Moolenaar | 08f4157 | 2020-04-20 16:50:00 +0200 | [diff] [blame] | 371 | " vim: shiftwidth=2 sts=2 expandtab |