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