Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 1 | " Test for reset 'scroll' and 'smoothscroll' |
| 2 | |
| 3 | source check.vim |
| 4 | source screendump.vim |
Bram Moolenaar | af2d20c | 2017-10-29 15:26:57 +0100 | [diff] [blame] | 5 | |
| 6 | func Test_reset_scroll() |
| 7 | let scr = &l:scroll |
| 8 | |
| 9 | setlocal scroll=1 |
| 10 | setlocal scroll& |
| 11 | call assert_equal(scr, &l:scroll) |
| 12 | |
| 13 | setlocal scroll=1 |
| 14 | setlocal scroll=0 |
| 15 | call assert_equal(scr, &l:scroll) |
| 16 | |
| 17 | try |
| 18 | execute 'setlocal scroll=' . (winheight(0) + 1) |
| 19 | " not reached |
| 20 | call assert_false(1) |
| 21 | catch |
| 22 | call assert_exception('E49:') |
| 23 | endtry |
| 24 | |
| 25 | split |
| 26 | |
| 27 | let scr = &l:scroll |
| 28 | |
| 29 | setlocal scroll=1 |
| 30 | setlocal scroll& |
| 31 | call assert_equal(scr, &l:scroll) |
| 32 | |
| 33 | setlocal scroll=1 |
| 34 | setlocal scroll=0 |
| 35 | call assert_equal(scr, &l:scroll) |
| 36 | |
| 37 | quit! |
| 38 | endfunc |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 39 | |
Bram Moolenaar | 8df9748 | 2022-10-03 12:11:13 +0100 | [diff] [blame] | 40 | func Test_CtrlE_CtrlY_stop_at_end() |
| 41 | enew |
| 42 | call setline(1, ['one', 'two']) |
| 43 | set number |
| 44 | exe "normal \<C-Y>" |
| 45 | call assert_equal([" 1 one "], ScreenLines(1, 10)) |
| 46 | exe "normal \<C-E>\<C-E>\<C-E>" |
| 47 | call assert_equal([" 2 two "], ScreenLines(1, 10)) |
| 48 | |
| 49 | bwipe! |
| 50 | set nonumber |
| 51 | endfunc |
| 52 | |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 53 | func Test_smoothscroll_CtrlE_CtrlY() |
| 54 | CheckScreendump |
| 55 | |
| 56 | let lines =<< trim END |
| 57 | vim9script |
| 58 | setline(1, [ |
| 59 | 'line one', |
| 60 | 'word '->repeat(20), |
| 61 | 'line three', |
| 62 | 'long word '->repeat(7), |
| 63 | 'line', |
| 64 | 'line', |
| 65 | 'line', |
| 66 | ]) |
| 67 | set smoothscroll |
| 68 | :5 |
| 69 | END |
| 70 | call writefile(lines, 'XSmoothScroll', 'D') |
| 71 | let buf = RunVimInTerminal('-S XSmoothScroll', #{rows: 12, cols: 40}) |
| 72 | |
| 73 | call term_sendkeys(buf, "\<C-E>") |
| 74 | call VerifyScreenDump(buf, 'Test_smoothscroll_1', {}) |
| 75 | call term_sendkeys(buf, "\<C-E>") |
| 76 | call VerifyScreenDump(buf, 'Test_smoothscroll_2', {}) |
| 77 | call term_sendkeys(buf, "\<C-E>") |
| 78 | call VerifyScreenDump(buf, 'Test_smoothscroll_3', {}) |
| 79 | call term_sendkeys(buf, "\<C-E>") |
| 80 | call VerifyScreenDump(buf, 'Test_smoothscroll_4', {}) |
| 81 | |
| 82 | call term_sendkeys(buf, "\<C-Y>") |
| 83 | call VerifyScreenDump(buf, 'Test_smoothscroll_5', {}) |
| 84 | call term_sendkeys(buf, "\<C-Y>") |
| 85 | call VerifyScreenDump(buf, 'Test_smoothscroll_6', {}) |
| 86 | call term_sendkeys(buf, "\<C-Y>") |
| 87 | call VerifyScreenDump(buf, 'Test_smoothscroll_7', {}) |
| 88 | call term_sendkeys(buf, "\<C-Y>") |
| 89 | call VerifyScreenDump(buf, 'Test_smoothscroll_8', {}) |
| 90 | |
Bram Moolenaar | 6b2d4ff | 2022-10-03 14:06:02 +0100 | [diff] [blame] | 91 | if has('folding') |
| 92 | call term_sendkeys(buf, ":set foldmethod=indent\<CR>") |
| 93 | " move the cursor so we can reuse the same dumps |
| 94 | call term_sendkeys(buf, "5G") |
| 95 | call term_sendkeys(buf, "\<C-E>") |
| 96 | call VerifyScreenDump(buf, 'Test_smoothscroll_1', {}) |
| 97 | call term_sendkeys(buf, "\<C-E>") |
| 98 | call VerifyScreenDump(buf, 'Test_smoothscroll_2', {}) |
| 99 | call term_sendkeys(buf, "7G") |
| 100 | call term_sendkeys(buf, "\<C-Y>") |
| 101 | call VerifyScreenDump(buf, 'Test_smoothscroll_7', {}) |
| 102 | call term_sendkeys(buf, "\<C-Y>") |
| 103 | call VerifyScreenDump(buf, 'Test_smoothscroll_8', {}) |
| 104 | endif |
| 105 | |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 106 | call StopVimInTerminal(buf) |
| 107 | endfunc |
| 108 | |
Bram Moolenaar | b6aab8f | 2022-10-03 20:01:16 +0100 | [diff] [blame] | 109 | func Test_smoothscroll_number() |
| 110 | CheckScreendump |
| 111 | |
| 112 | let lines =<< trim END |
| 113 | vim9script |
| 114 | setline(1, [ |
| 115 | 'one ' .. 'word '->repeat(20), |
| 116 | 'two ' .. 'long word '->repeat(7), |
| 117 | 'line', |
| 118 | 'line', |
| 119 | 'line', |
| 120 | ]) |
| 121 | set smoothscroll |
| 122 | set number cpo+=n |
| 123 | :3 |
Bram Moolenaar | eb4de62 | 2022-10-15 13:42:17 +0100 | [diff] [blame] | 124 | |
| 125 | def g:DoRel() |
| 126 | set number relativenumber scrolloff=0 |
| 127 | :%del |
| 128 | setline(1, [ |
| 129 | 'one', |
| 130 | 'very long text '->repeat(12), |
| 131 | 'three', |
| 132 | ]) |
| 133 | exe "normal 2Gzt\<C-E>" |
| 134 | enddef |
Bram Moolenaar | b6aab8f | 2022-10-03 20:01:16 +0100 | [diff] [blame] | 135 | END |
| 136 | call writefile(lines, 'XSmoothNumber', 'D') |
| 137 | let buf = RunVimInTerminal('-S XSmoothNumber', #{rows: 12, cols: 40}) |
| 138 | |
| 139 | call VerifyScreenDump(buf, 'Test_smooth_number_1', {}) |
| 140 | call term_sendkeys(buf, "\<C-E>") |
| 141 | call VerifyScreenDump(buf, 'Test_smooth_number_2', {}) |
| 142 | call term_sendkeys(buf, "\<C-E>") |
| 143 | call VerifyScreenDump(buf, 'Test_smooth_number_3', {}) |
| 144 | |
| 145 | call term_sendkeys(buf, ":set cpo-=n\<CR>") |
| 146 | call VerifyScreenDump(buf, 'Test_smooth_number_4', {}) |
| 147 | call term_sendkeys(buf, "\<C-Y>") |
| 148 | call VerifyScreenDump(buf, 'Test_smooth_number_5', {}) |
| 149 | call term_sendkeys(buf, "\<C-Y>") |
| 150 | call VerifyScreenDump(buf, 'Test_smooth_number_6', {}) |
| 151 | |
Bram Moolenaar | eb4de62 | 2022-10-15 13:42:17 +0100 | [diff] [blame] | 152 | call term_sendkeys(buf, ":call DoRel()\<CR>") |
| 153 | call VerifyScreenDump(buf, 'Test_smooth_number_7', {}) |
| 154 | |
Bram Moolenaar | b6aab8f | 2022-10-03 20:01:16 +0100 | [diff] [blame] | 155 | call StopVimInTerminal(buf) |
| 156 | endfunc |
| 157 | |
Bram Moolenaar | 13cdde3 | 2022-10-15 14:07:48 +0100 | [diff] [blame] | 158 | func Test_smoothscroll_list() |
| 159 | CheckScreendump |
| 160 | |
| 161 | let lines =<< trim END |
| 162 | vim9script |
| 163 | set smoothscroll scrolloff=0 |
| 164 | set list |
| 165 | setline(1, [ |
| 166 | 'one', |
| 167 | 'very long text '->repeat(12), |
| 168 | 'three', |
| 169 | ]) |
| 170 | exe "normal 2Gzt\<C-E>" |
| 171 | END |
| 172 | call writefile(lines, 'XSmoothList', 'D') |
| 173 | let buf = RunVimInTerminal('-S XSmoothList', #{rows: 8, cols: 40}) |
| 174 | |
| 175 | call VerifyScreenDump(buf, 'Test_smooth_list_1', {}) |
| 176 | |
| 177 | call term_sendkeys(buf, ":set listchars+=precedes:#\<CR>") |
| 178 | call VerifyScreenDump(buf, 'Test_smooth_list_2', {}) |
| 179 | |
| 180 | call StopVimInTerminal(buf) |
| 181 | endfunc |
| 182 | |
Bram Moolenaar | 1a58e1d | 2022-10-06 13:09:17 +0100 | [diff] [blame] | 183 | func Test_smoothscroll_diff_mode() |
| 184 | CheckScreendump |
| 185 | |
| 186 | let lines =<< trim END |
| 187 | vim9script |
| 188 | var text = 'just some text here' |
| 189 | setline(1, text) |
| 190 | set smoothscroll |
| 191 | diffthis |
| 192 | new |
| 193 | setline(1, text) |
| 194 | set smoothscroll |
| 195 | diffthis |
| 196 | END |
| 197 | call writefile(lines, 'XSmoothDiff', 'D') |
| 198 | let buf = RunVimInTerminal('-S XSmoothDiff', #{rows: 8}) |
| 199 | |
| 200 | call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) |
| 201 | call term_sendkeys(buf, "\<C-Y>") |
| 202 | call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) |
| 203 | call term_sendkeys(buf, "\<C-E>") |
| 204 | call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) |
| 205 | |
| 206 | call StopVimInTerminal(buf) |
| 207 | endfunc |
| 208 | |
Bram Moolenaar | 9bab7a0 | 2022-10-06 14:57:53 +0100 | [diff] [blame] | 209 | func Test_smoothscroll_wrap_scrolloff_zero() |
| 210 | CheckScreendump |
| 211 | |
| 212 | let lines =<< trim END |
| 213 | vim9script |
| 214 | setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7)) |
| 215 | set smoothscroll scrolloff=0 |
| 216 | :3 |
| 217 | END |
| 218 | call writefile(lines, 'XSmoothWrap', 'D') |
| 219 | let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 8, cols: 40}) |
| 220 | |
| 221 | call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {}) |
| 222 | |
Bram Moolenaar | 46b5474 | 2022-10-06 15:46:49 +0100 | [diff] [blame] | 223 | " moving cursor down - whole bottom line shows |
Bram Moolenaar | 9bab7a0 | 2022-10-06 14:57:53 +0100 | [diff] [blame] | 224 | call term_sendkeys(buf, "j") |
| 225 | call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {}) |
| 226 | |
| 227 | call term_sendkeys(buf, "\<C-E>j") |
| 228 | call VerifyScreenDump(buf, 'Test_smooth_wrap_3', {}) |
| 229 | |
| 230 | call term_sendkeys(buf, "G") |
| 231 | call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {}) |
| 232 | |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 233 | " moving cursor up right after the >>> marker - no need to show whole line |
| 234 | call term_sendkeys(buf, "2gj3l2k") |
Bram Moolenaar | 46b5474 | 2022-10-06 15:46:49 +0100 | [diff] [blame] | 235 | call VerifyScreenDump(buf, 'Test_smooth_wrap_5', {}) |
| 236 | |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 237 | " moving cursor up where the >>> marker is - whole top line shows |
| 238 | call term_sendkeys(buf, "2j02k") |
| 239 | call VerifyScreenDump(buf, 'Test_smooth_wrap_6', {}) |
| 240 | |
Bram Moolenaar | 9bab7a0 | 2022-10-06 14:57:53 +0100 | [diff] [blame] | 241 | call StopVimInTerminal(buf) |
| 242 | endfunc |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 243 | |
Bram Moolenaar | 8cf3459 | 2022-10-08 21:13:40 +0100 | [diff] [blame] | 244 | func Test_smoothscroll_wrap_long_line() |
| 245 | CheckScreendump |
| 246 | |
| 247 | let lines =<< trim END |
| 248 | vim9script |
Yee Cheng Chin | 361895d | 2022-11-19 12:25:16 +0000 | [diff] [blame] | 249 | setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(30)) .. ' end', 'four']) |
Bram Moolenaar | 8cf3459 | 2022-10-08 21:13:40 +0100 | [diff] [blame] | 250 | set smoothscroll scrolloff=0 |
| 251 | normal 3G10|zt |
| 252 | END |
| 253 | call writefile(lines, 'XSmoothWrap', 'D') |
| 254 | let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 6, cols: 40}) |
| 255 | call VerifyScreenDump(buf, 'Test_smooth_long_1', {}) |
| 256 | |
| 257 | " scrolling up, cursor moves screen line down |
| 258 | call term_sendkeys(buf, "\<C-E>") |
| 259 | call VerifyScreenDump(buf, 'Test_smooth_long_2', {}) |
| 260 | call term_sendkeys(buf, "5\<C-E>") |
| 261 | call VerifyScreenDump(buf, 'Test_smooth_long_3', {}) |
| 262 | |
| 263 | " scrolling down, cursor moves screen line up |
| 264 | call term_sendkeys(buf, "5\<C-Y>") |
| 265 | call VerifyScreenDump(buf, 'Test_smooth_long_4', {}) |
| 266 | call term_sendkeys(buf, "\<C-Y>") |
| 267 | call VerifyScreenDump(buf, 'Test_smooth_long_5', {}) |
| 268 | |
Bram Moolenaar | 118c235 | 2022-10-09 17:19:27 +0100 | [diff] [blame] | 269 | " 'scrolloff' set to 1, scrolling up, cursor moves screen line down |
| 270 | call term_sendkeys(buf, ":set scrolloff=1\<CR>") |
| 271 | call term_sendkeys(buf, "10|\<C-E>") |
| 272 | call VerifyScreenDump(buf, 'Test_smooth_long_6', {}) |
| 273 | |
| 274 | " 'scrolloff' set to 1, scrolling down, cursor moves screen line up |
| 275 | call term_sendkeys(buf, "\<C-E>") |
| 276 | call term_sendkeys(buf, "gjgj") |
| 277 | call term_sendkeys(buf, "\<C-Y>") |
| 278 | call VerifyScreenDump(buf, 'Test_smooth_long_7', {}) |
| 279 | |
| 280 | " 'scrolloff' set to 2, scrolling up, cursor moves screen line down |
| 281 | call term_sendkeys(buf, ":set scrolloff=2\<CR>") |
| 282 | call term_sendkeys(buf, "10|\<C-E>") |
| 283 | call VerifyScreenDump(buf, 'Test_smooth_long_8', {}) |
| 284 | |
| 285 | " 'scrolloff' set to 2, scrolling down, cursor moves screen line up |
| 286 | call term_sendkeys(buf, "\<C-E>") |
| 287 | call term_sendkeys(buf, "gj") |
| 288 | call term_sendkeys(buf, "\<C-Y>") |
| 289 | call VerifyScreenDump(buf, 'Test_smooth_long_9', {}) |
Yee Cheng Chin | 361895d | 2022-11-19 12:25:16 +0000 | [diff] [blame] | 290 | |
| 291 | " 'scrolloff' set to 0, move cursor down one line. |
| 292 | " Cursor should move properly, and since this is a really long line, it will |
| 293 | " be put on top of the screen. |
| 294 | call term_sendkeys(buf, ":set scrolloff=0\<CR>") |
| 295 | call term_sendkeys(buf, "0j") |
| 296 | call VerifyScreenDump(buf, 'Test_smooth_long_10', {}) |
| 297 | |
| 298 | " Repeat the step and move the cursor down again. |
| 299 | " This time, use a shorter long line that is barely long enough to span more |
| 300 | " than one window. Note that the cursor is at the bottom this time because |
| 301 | " Vim prefers to do so if we are scrolling a few lines only. |
| 302 | call term_sendkeys(buf, ":call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(10)) .. ' end', 'four'])\<CR>") |
| 303 | call term_sendkeys(buf, "3Gzt") |
| 304 | call term_sendkeys(buf, "j") |
| 305 | call VerifyScreenDump(buf, 'Test_smooth_long_11', {}) |
| 306 | |
| 307 | " Repeat the step but this time start it when the line is smooth-scrolled by |
| 308 | " one line. This tests that the offset calculation is still correct and |
| 309 | " still end up scrolling down to the next line with cursor at bottom of |
| 310 | " screen. |
| 311 | call term_sendkeys(buf, "3Gzt") |
| 312 | call term_sendkeys(buf, "\<C-E>j") |
| 313 | call VerifyScreenDump(buf, 'Test_smooth_long_12', {}) |
Bram Moolenaar | 118c235 | 2022-10-09 17:19:27 +0100 | [diff] [blame] | 314 | |
Bram Moolenaar | 8cf3459 | 2022-10-08 21:13:40 +0100 | [diff] [blame] | 315 | call StopVimInTerminal(buf) |
| 316 | endfunc |
| 317 | |
Bram Moolenaar | 2fbabd2 | 2022-10-12 19:53:38 +0100 | [diff] [blame] | 318 | func Test_smoothscroll_one_long_line() |
| 319 | CheckScreendump |
| 320 | |
| 321 | let lines =<< trim END |
| 322 | vim9script |
| 323 | setline(1, 'with lots of text '->repeat(7)) |
| 324 | set smoothscroll scrolloff=0 |
| 325 | END |
| 326 | call writefile(lines, 'XSmoothOneLong', 'D') |
| 327 | let buf = RunVimInTerminal('-S XSmoothOneLong', #{rows: 6, cols: 40}) |
| 328 | call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {}) |
| 329 | |
| 330 | call term_sendkeys(buf, "\<C-E>") |
| 331 | call VerifyScreenDump(buf, 'Test_smooth_one_long_2', {}) |
| 332 | |
| 333 | call term_sendkeys(buf, "0") |
| 334 | call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {}) |
| 335 | |
| 336 | call StopVimInTerminal(buf) |
| 337 | endfunc |
| 338 | |
Bram Moolenaar | 75ac25b | 2022-11-17 19:00:14 +0000 | [diff] [blame] | 339 | func Test_smoothscroll_long_line_showbreak() |
| 340 | CheckScreendump |
| 341 | |
| 342 | let lines =<< trim END |
| 343 | vim9script |
| 344 | # a line that spans four screen lines |
| 345 | setline(1, 'with lots of text in one line '->repeat(6)) |
| 346 | set smoothscroll scrolloff=0 showbreak=+++\ |
| 347 | END |
| 348 | call writefile(lines, 'XSmoothLongShowbreak', 'D') |
| 349 | let buf = RunVimInTerminal('-S XSmoothLongShowbreak', #{rows: 6, cols: 40}) |
| 350 | call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {}) |
| 351 | |
Bram Moolenaar | 75ac25b | 2022-11-17 19:00:14 +0000 | [diff] [blame] | 352 | call term_sendkeys(buf, "\<C-E>") |
| 353 | call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_2', {}) |
| 354 | |
| 355 | call term_sendkeys(buf, "0") |
| 356 | call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {}) |
| 357 | |
| 358 | call StopVimInTerminal(buf) |
| 359 | endfunc |
| 360 | |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 361 | " Test that if the current cursor is on a smooth scrolled line, we correctly |
| 362 | " reposition it. Also check that we don't miscalculate the values by checking |
| 363 | " the consistency between wincol() and col('.') as they are calculated |
| 364 | " separately in code. |
| 365 | func Test_smoothscroll_cursor_position() |
| 366 | call NewWindow(10, 20) |
| 367 | setl smoothscroll wrap |
| 368 | call setline(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
| 369 | |
| 370 | func s:check_col_calc(win_col, win_line, buf_col) |
| 371 | call assert_equal(a:win_col, wincol()) |
| 372 | call assert_equal(a:win_line, winline()) |
| 373 | call assert_equal(a:buf_col, col('.')) |
| 374 | endfunc |
| 375 | |
| 376 | call s:check_col_calc(1, 1, 1) |
| 377 | exe "normal \<C-E>" |
| 378 | |
| 379 | " Move down another line to avoid blocking the <<< display |
| 380 | call s:check_col_calc(1, 2, 41) |
| 381 | exe "normal \<C-Y>" |
| 382 | call s:check_col_calc(1, 3, 41) |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 383 | |
| 384 | normal gg3l |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 385 | exe "normal \<C-E>" |
| 386 | |
| 387 | " Move down only 1 line when we are out of the range of the <<< display |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 388 | call s:check_col_calc(4, 1, 24) |
| 389 | exe "normal \<C-Y>" |
| 390 | call s:check_col_calc(4, 2, 24) |
| 391 | normal ggg$ |
| 392 | exe "normal \<C-E>" |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 393 | call s:check_col_calc(20, 1, 40) |
| 394 | exe "normal \<C-Y>" |
| 395 | call s:check_col_calc(20, 2, 40) |
| 396 | normal gg |
| 397 | |
| 398 | " Test number, where we have indented lines |
| 399 | setl number |
| 400 | call s:check_col_calc(5, 1, 1) |
| 401 | exe "normal \<C-E>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 402 | |
| 403 | " Move down only 1 line when the <<< display is on the number column |
| 404 | call s:check_col_calc(5, 1, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 405 | exe "normal \<C-Y>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 406 | call s:check_col_calc(5, 2, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 407 | normal ggg$ |
| 408 | exe "normal \<C-E>" |
| 409 | call s:check_col_calc(20, 1, 32) |
| 410 | exe "normal \<C-Y>" |
| 411 | call s:check_col_calc(20, 2, 32) |
| 412 | normal gg |
| 413 | |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 414 | setl numberwidth=1 |
| 415 | |
| 416 | " Move down another line when numberwidth is too short to cover the whole |
| 417 | " <<< display |
| 418 | call s:check_col_calc(3, 1, 1) |
| 419 | exe "normal \<C-E>" |
| 420 | call s:check_col_calc(3, 2, 37) |
| 421 | exe "normal \<C-Y>" |
| 422 | call s:check_col_calc(3, 3, 37) |
| 423 | normal ggl |
| 424 | |
| 425 | " Only move 1 line down when we are just past the <<< display |
| 426 | call s:check_col_calc(4, 1, 2) |
| 427 | exe "normal \<C-E>" |
| 428 | call s:check_col_calc(4, 1, 20) |
| 429 | exe "normal \<C-Y>" |
| 430 | call s:check_col_calc(4, 2, 20) |
| 431 | normal gg |
| 432 | setl numberwidth& |
| 433 | |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 434 | " Test number + showbreak, so test that the additional indentation works |
| 435 | setl number showbreak=+++ |
| 436 | call s:check_col_calc(5, 1, 1) |
| 437 | exe "normal \<C-E>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 438 | call s:check_col_calc(8, 1, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 439 | exe "normal \<C-Y>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 440 | call s:check_col_calc(8, 2, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 441 | normal gg |
| 442 | |
| 443 | " Test number + cpo+=n mode, where wrapped lines aren't indented |
| 444 | setl number cpo+=n showbreak= |
| 445 | call s:check_col_calc(5, 1, 1) |
| 446 | exe "normal \<C-E>" |
| 447 | call s:check_col_calc(1, 2, 37) |
| 448 | exe "normal \<C-Y>" |
| 449 | call s:check_col_calc(1, 3, 37) |
| 450 | normal gg |
| 451 | |
| 452 | bwipeout! |
| 453 | endfunc |
| 454 | |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 455 | |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 456 | " vim: shiftwidth=2 sts=2 expandtab |