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 |
Yee Cheng Chin | e6392b1 | 2022-11-19 14:31:08 +0000 | [diff] [blame] | 5 | source mouse.vim |
Bram Moolenaar | af2d20c | 2017-10-29 15:26:57 +0100 | [diff] [blame] | 6 | |
| 7 | func Test_reset_scroll() |
| 8 | let scr = &l:scroll |
| 9 | |
| 10 | setlocal scroll=1 |
| 11 | setlocal scroll& |
| 12 | call assert_equal(scr, &l:scroll) |
| 13 | |
| 14 | setlocal scroll=1 |
| 15 | setlocal scroll=0 |
| 16 | call assert_equal(scr, &l:scroll) |
| 17 | |
| 18 | try |
| 19 | execute 'setlocal scroll=' . (winheight(0) + 1) |
| 20 | " not reached |
| 21 | call assert_false(1) |
| 22 | catch |
| 23 | call assert_exception('E49:') |
| 24 | endtry |
| 25 | |
| 26 | split |
| 27 | |
| 28 | let scr = &l:scroll |
| 29 | |
| 30 | setlocal scroll=1 |
| 31 | setlocal scroll& |
| 32 | call assert_equal(scr, &l:scroll) |
| 33 | |
| 34 | setlocal scroll=1 |
| 35 | setlocal scroll=0 |
| 36 | call assert_equal(scr, &l:scroll) |
| 37 | |
| 38 | quit! |
| 39 | endfunc |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 40 | |
Bram Moolenaar | 1d6539c | 2023-02-14 17:41:20 +0000 | [diff] [blame] | 41 | func Test_scolloff_even_line_count() |
| 42 | new |
| 43 | resize 6 |
| 44 | setlocal scrolloff=3 |
| 45 | call setline(1, range(20)) |
| 46 | normal 2j |
| 47 | call assert_equal(1, getwininfo(win_getid())[0].topline) |
| 48 | normal j |
| 49 | call assert_equal(1, getwininfo(win_getid())[0].topline) |
| 50 | normal j |
| 51 | call assert_equal(2, getwininfo(win_getid())[0].topline) |
| 52 | normal j |
| 53 | call assert_equal(3, getwininfo(win_getid())[0].topline) |
| 54 | |
| 55 | bwipe! |
| 56 | endfunc |
| 57 | |
Bram Moolenaar | 8df9748 | 2022-10-03 12:11:13 +0100 | [diff] [blame] | 58 | func Test_CtrlE_CtrlY_stop_at_end() |
| 59 | enew |
| 60 | call setline(1, ['one', 'two']) |
| 61 | set number |
| 62 | exe "normal \<C-Y>" |
| 63 | call assert_equal([" 1 one "], ScreenLines(1, 10)) |
| 64 | exe "normal \<C-E>\<C-E>\<C-E>" |
| 65 | call assert_equal([" 2 two "], ScreenLines(1, 10)) |
| 66 | |
| 67 | bwipe! |
| 68 | set nonumber |
| 69 | endfunc |
| 70 | |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 71 | func Test_smoothscroll_CtrlE_CtrlY() |
| 72 | CheckScreendump |
| 73 | |
| 74 | let lines =<< trim END |
| 75 | vim9script |
| 76 | setline(1, [ |
| 77 | 'line one', |
| 78 | 'word '->repeat(20), |
| 79 | 'line three', |
| 80 | 'long word '->repeat(7), |
| 81 | 'line', |
| 82 | 'line', |
| 83 | 'line', |
| 84 | ]) |
| 85 | set smoothscroll |
| 86 | :5 |
| 87 | END |
| 88 | call writefile(lines, 'XSmoothScroll', 'D') |
| 89 | let buf = RunVimInTerminal('-S XSmoothScroll', #{rows: 12, cols: 40}) |
| 90 | |
| 91 | call term_sendkeys(buf, "\<C-E>") |
| 92 | call VerifyScreenDump(buf, 'Test_smoothscroll_1', {}) |
| 93 | call term_sendkeys(buf, "\<C-E>") |
| 94 | call VerifyScreenDump(buf, 'Test_smoothscroll_2', {}) |
| 95 | call term_sendkeys(buf, "\<C-E>") |
| 96 | call VerifyScreenDump(buf, 'Test_smoothscroll_3', {}) |
| 97 | call term_sendkeys(buf, "\<C-E>") |
| 98 | call VerifyScreenDump(buf, 'Test_smoothscroll_4', {}) |
| 99 | |
| 100 | call term_sendkeys(buf, "\<C-Y>") |
| 101 | call VerifyScreenDump(buf, 'Test_smoothscroll_5', {}) |
| 102 | call term_sendkeys(buf, "\<C-Y>") |
| 103 | call VerifyScreenDump(buf, 'Test_smoothscroll_6', {}) |
| 104 | call term_sendkeys(buf, "\<C-Y>") |
| 105 | call VerifyScreenDump(buf, 'Test_smoothscroll_7', {}) |
| 106 | call term_sendkeys(buf, "\<C-Y>") |
| 107 | call VerifyScreenDump(buf, 'Test_smoothscroll_8', {}) |
| 108 | |
Bram Moolenaar | 6b2d4ff | 2022-10-03 14:06:02 +0100 | [diff] [blame] | 109 | if has('folding') |
| 110 | call term_sendkeys(buf, ":set foldmethod=indent\<CR>") |
| 111 | " move the cursor so we can reuse the same dumps |
| 112 | call term_sendkeys(buf, "5G") |
| 113 | call term_sendkeys(buf, "\<C-E>") |
| 114 | call VerifyScreenDump(buf, 'Test_smoothscroll_1', {}) |
| 115 | call term_sendkeys(buf, "\<C-E>") |
| 116 | call VerifyScreenDump(buf, 'Test_smoothscroll_2', {}) |
| 117 | call term_sendkeys(buf, "7G") |
| 118 | call term_sendkeys(buf, "\<C-Y>") |
| 119 | call VerifyScreenDump(buf, 'Test_smoothscroll_7', {}) |
| 120 | call term_sendkeys(buf, "\<C-Y>") |
| 121 | call VerifyScreenDump(buf, 'Test_smoothscroll_8', {}) |
| 122 | endif |
| 123 | |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 124 | call StopVimInTerminal(buf) |
| 125 | endfunc |
| 126 | |
Bram Moolenaar | 15d4747 | 2023-06-05 20:44:55 +0100 | [diff] [blame^] | 127 | func Test_smoothscroll_multibyte() |
| 128 | CheckScreendump |
| 129 | |
| 130 | let lines =<< trim END |
| 131 | set scrolloff=0 smoothscroll |
| 132 | call setline(1, [repeat('ϛ', 45), repeat('2', 36)]) |
| 133 | exe "normal G35l\<C-E>k" |
| 134 | END |
| 135 | call writefile(lines, 'XSmoothMultibyte', 'D') |
| 136 | let buf = RunVimInTerminal('-S XSmoothMultibyte', #{rows: 6, cols: 40}) |
| 137 | call VerifyScreenDump(buf, 'Test_smoothscroll_multi_1', {}) |
| 138 | |
| 139 | call StopVimInTerminal(buf) |
| 140 | endfunc |
| 141 | |
Bram Moolenaar | b6aab8f | 2022-10-03 20:01:16 +0100 | [diff] [blame] | 142 | func Test_smoothscroll_number() |
| 143 | CheckScreendump |
| 144 | |
| 145 | let lines =<< trim END |
| 146 | vim9script |
| 147 | setline(1, [ |
| 148 | 'one ' .. 'word '->repeat(20), |
| 149 | 'two ' .. 'long word '->repeat(7), |
| 150 | 'line', |
| 151 | 'line', |
| 152 | 'line', |
| 153 | ]) |
| 154 | set smoothscroll |
zeertzjq | 88bb3e0 | 2023-05-02 20:52:59 +0100 | [diff] [blame] | 155 | set splitkeep=topline |
Bram Moolenaar | b6aab8f | 2022-10-03 20:01:16 +0100 | [diff] [blame] | 156 | set number cpo+=n |
| 157 | :3 |
Bram Moolenaar | eb4de62 | 2022-10-15 13:42:17 +0100 | [diff] [blame] | 158 | |
| 159 | def g:DoRel() |
| 160 | set number relativenumber scrolloff=0 |
| 161 | :%del |
| 162 | setline(1, [ |
| 163 | 'one', |
| 164 | 'very long text '->repeat(12), |
| 165 | 'three', |
| 166 | ]) |
| 167 | exe "normal 2Gzt\<C-E>" |
| 168 | enddef |
Bram Moolenaar | b6aab8f | 2022-10-03 20:01:16 +0100 | [diff] [blame] | 169 | END |
| 170 | call writefile(lines, 'XSmoothNumber', 'D') |
| 171 | let buf = RunVimInTerminal('-S XSmoothNumber', #{rows: 12, cols: 40}) |
| 172 | |
| 173 | call VerifyScreenDump(buf, 'Test_smooth_number_1', {}) |
| 174 | call term_sendkeys(buf, "\<C-E>") |
| 175 | call VerifyScreenDump(buf, 'Test_smooth_number_2', {}) |
| 176 | call term_sendkeys(buf, "\<C-E>") |
| 177 | call VerifyScreenDump(buf, 'Test_smooth_number_3', {}) |
| 178 | |
| 179 | call term_sendkeys(buf, ":set cpo-=n\<CR>") |
| 180 | call VerifyScreenDump(buf, 'Test_smooth_number_4', {}) |
| 181 | call term_sendkeys(buf, "\<C-Y>") |
| 182 | call VerifyScreenDump(buf, 'Test_smooth_number_5', {}) |
| 183 | call term_sendkeys(buf, "\<C-Y>") |
| 184 | call VerifyScreenDump(buf, 'Test_smooth_number_6', {}) |
| 185 | |
zeertzjq | 88bb3e0 | 2023-05-02 20:52:59 +0100 | [diff] [blame] | 186 | call term_sendkeys(buf, ":botright split\<CR>gg") |
Bram Moolenaar | eb4de62 | 2022-10-15 13:42:17 +0100 | [diff] [blame] | 187 | call VerifyScreenDump(buf, 'Test_smooth_number_7', {}) |
zeertzjq | 88bb3e0 | 2023-05-02 20:52:59 +0100 | [diff] [blame] | 188 | call term_sendkeys(buf, "\<C-E>") |
| 189 | call VerifyScreenDump(buf, 'Test_smooth_number_8', {}) |
| 190 | call term_sendkeys(buf, "\<C-E>") |
| 191 | call VerifyScreenDump(buf, 'Test_smooth_number_9', {}) |
| 192 | call term_sendkeys(buf, ":close\<CR>") |
| 193 | |
| 194 | call term_sendkeys(buf, ":call DoRel()\<CR>") |
| 195 | call VerifyScreenDump(buf, 'Test_smooth_number_10', {}) |
Bram Moolenaar | eb4de62 | 2022-10-15 13:42:17 +0100 | [diff] [blame] | 196 | |
Bram Moolenaar | b6aab8f | 2022-10-03 20:01:16 +0100 | [diff] [blame] | 197 | call StopVimInTerminal(buf) |
| 198 | endfunc |
| 199 | |
Bram Moolenaar | 13cdde3 | 2022-10-15 14:07:48 +0100 | [diff] [blame] | 200 | func Test_smoothscroll_list() |
| 201 | CheckScreendump |
| 202 | |
| 203 | let lines =<< trim END |
| 204 | vim9script |
| 205 | set smoothscroll scrolloff=0 |
| 206 | set list |
| 207 | setline(1, [ |
| 208 | 'one', |
| 209 | 'very long text '->repeat(12), |
| 210 | 'three', |
| 211 | ]) |
| 212 | exe "normal 2Gzt\<C-E>" |
| 213 | END |
| 214 | call writefile(lines, 'XSmoothList', 'D') |
| 215 | let buf = RunVimInTerminal('-S XSmoothList', #{rows: 8, cols: 40}) |
| 216 | |
| 217 | call VerifyScreenDump(buf, 'Test_smooth_list_1', {}) |
| 218 | |
| 219 | call term_sendkeys(buf, ":set listchars+=precedes:#\<CR>") |
| 220 | call VerifyScreenDump(buf, 'Test_smooth_list_2', {}) |
| 221 | |
| 222 | call StopVimInTerminal(buf) |
| 223 | endfunc |
| 224 | |
Bram Moolenaar | 1a58e1d | 2022-10-06 13:09:17 +0100 | [diff] [blame] | 225 | func Test_smoothscroll_diff_mode() |
| 226 | CheckScreendump |
| 227 | |
| 228 | let lines =<< trim END |
| 229 | vim9script |
| 230 | var text = 'just some text here' |
| 231 | setline(1, text) |
| 232 | set smoothscroll |
| 233 | diffthis |
| 234 | new |
| 235 | setline(1, text) |
| 236 | set smoothscroll |
| 237 | diffthis |
| 238 | END |
| 239 | call writefile(lines, 'XSmoothDiff', 'D') |
| 240 | let buf = RunVimInTerminal('-S XSmoothDiff', #{rows: 8}) |
| 241 | |
| 242 | call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) |
| 243 | call term_sendkeys(buf, "\<C-Y>") |
| 244 | call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) |
| 245 | call term_sendkeys(buf, "\<C-E>") |
| 246 | call VerifyScreenDump(buf, 'Test_smooth_diff_1', {}) |
| 247 | |
| 248 | call StopVimInTerminal(buf) |
| 249 | endfunc |
| 250 | |
Bram Moolenaar | 9bab7a0 | 2022-10-06 14:57:53 +0100 | [diff] [blame] | 251 | func Test_smoothscroll_wrap_scrolloff_zero() |
| 252 | CheckScreendump |
| 253 | |
| 254 | let lines =<< trim END |
| 255 | vim9script |
| 256 | setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7)) |
| 257 | set smoothscroll scrolloff=0 |
| 258 | :3 |
| 259 | END |
| 260 | call writefile(lines, 'XSmoothWrap', 'D') |
| 261 | let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 8, cols: 40}) |
| 262 | |
| 263 | call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {}) |
| 264 | |
Bram Moolenaar | 46b5474 | 2022-10-06 15:46:49 +0100 | [diff] [blame] | 265 | " moving cursor down - whole bottom line shows |
Bram Moolenaar | 9bab7a0 | 2022-10-06 14:57:53 +0100 | [diff] [blame] | 266 | call term_sendkeys(buf, "j") |
| 267 | call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {}) |
| 268 | |
| 269 | call term_sendkeys(buf, "\<C-E>j") |
| 270 | call VerifyScreenDump(buf, 'Test_smooth_wrap_3', {}) |
| 271 | |
| 272 | call term_sendkeys(buf, "G") |
| 273 | call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {}) |
| 274 | |
Luuk van Baal | d49f646 | 2023-05-19 14:04:47 +0100 | [diff] [blame] | 275 | call term_sendkeys(buf, "4\<C-Y>G") |
| 276 | call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {}) |
| 277 | |
| 278 | " moving cursor up right after the <<< marker - no need to show whole line |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 279 | call term_sendkeys(buf, "2gj3l2k") |
Bram Moolenaar | 46b5474 | 2022-10-06 15:46:49 +0100 | [diff] [blame] | 280 | call VerifyScreenDump(buf, 'Test_smooth_wrap_5', {}) |
| 281 | |
Luuk van Baal | d49f646 | 2023-05-19 14:04:47 +0100 | [diff] [blame] | 282 | " moving cursor up where the <<< marker is - whole top line shows |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 283 | call term_sendkeys(buf, "2j02k") |
| 284 | call VerifyScreenDump(buf, 'Test_smooth_wrap_6', {}) |
| 285 | |
Bram Moolenaar | 9bab7a0 | 2022-10-06 14:57:53 +0100 | [diff] [blame] | 286 | call StopVimInTerminal(buf) |
| 287 | endfunc |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 288 | |
Bram Moolenaar | 8cf3459 | 2022-10-08 21:13:40 +0100 | [diff] [blame] | 289 | func Test_smoothscroll_wrap_long_line() |
| 290 | CheckScreendump |
| 291 | |
| 292 | let lines =<< trim END |
| 293 | vim9script |
Yee Cheng Chin | 361895d | 2022-11-19 12:25:16 +0000 | [diff] [blame] | 294 | 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] | 295 | set smoothscroll scrolloff=0 |
| 296 | normal 3G10|zt |
| 297 | END |
| 298 | call writefile(lines, 'XSmoothWrap', 'D') |
| 299 | let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 6, cols: 40}) |
| 300 | call VerifyScreenDump(buf, 'Test_smooth_long_1', {}) |
| 301 | |
| 302 | " scrolling up, cursor moves screen line down |
| 303 | call term_sendkeys(buf, "\<C-E>") |
| 304 | call VerifyScreenDump(buf, 'Test_smooth_long_2', {}) |
| 305 | call term_sendkeys(buf, "5\<C-E>") |
| 306 | call VerifyScreenDump(buf, 'Test_smooth_long_3', {}) |
| 307 | |
| 308 | " scrolling down, cursor moves screen line up |
| 309 | call term_sendkeys(buf, "5\<C-Y>") |
| 310 | call VerifyScreenDump(buf, 'Test_smooth_long_4', {}) |
| 311 | call term_sendkeys(buf, "\<C-Y>") |
| 312 | call VerifyScreenDump(buf, 'Test_smooth_long_5', {}) |
| 313 | |
Bram Moolenaar | 118c235 | 2022-10-09 17:19:27 +0100 | [diff] [blame] | 314 | " 'scrolloff' set to 1, scrolling up, cursor moves screen line down |
| 315 | call term_sendkeys(buf, ":set scrolloff=1\<CR>") |
| 316 | call term_sendkeys(buf, "10|\<C-E>") |
| 317 | call VerifyScreenDump(buf, 'Test_smooth_long_6', {}) |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 318 | |
Bram Moolenaar | 118c235 | 2022-10-09 17:19:27 +0100 | [diff] [blame] | 319 | " 'scrolloff' set to 1, scrolling down, cursor moves screen line up |
| 320 | call term_sendkeys(buf, "\<C-E>") |
| 321 | call term_sendkeys(buf, "gjgj") |
| 322 | call term_sendkeys(buf, "\<C-Y>") |
| 323 | call VerifyScreenDump(buf, 'Test_smooth_long_7', {}) |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 324 | |
Bram Moolenaar | 118c235 | 2022-10-09 17:19:27 +0100 | [diff] [blame] | 325 | " 'scrolloff' set to 2, scrolling up, cursor moves screen line down |
| 326 | call term_sendkeys(buf, ":set scrolloff=2\<CR>") |
| 327 | call term_sendkeys(buf, "10|\<C-E>") |
| 328 | call VerifyScreenDump(buf, 'Test_smooth_long_8', {}) |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 329 | |
Bram Moolenaar | 118c235 | 2022-10-09 17:19:27 +0100 | [diff] [blame] | 330 | " 'scrolloff' set to 2, scrolling down, cursor moves screen line up |
| 331 | call term_sendkeys(buf, "\<C-E>") |
| 332 | call term_sendkeys(buf, "gj") |
| 333 | call term_sendkeys(buf, "\<C-Y>") |
| 334 | call VerifyScreenDump(buf, 'Test_smooth_long_9', {}) |
Yee Cheng Chin | 361895d | 2022-11-19 12:25:16 +0000 | [diff] [blame] | 335 | |
| 336 | " 'scrolloff' set to 0, move cursor down one line. |
| 337 | " Cursor should move properly, and since this is a really long line, it will |
| 338 | " be put on top of the screen. |
| 339 | call term_sendkeys(buf, ":set scrolloff=0\<CR>") |
| 340 | call term_sendkeys(buf, "0j") |
| 341 | call VerifyScreenDump(buf, 'Test_smooth_long_10', {}) |
| 342 | |
Bram Moolenaar | db4d88c | 2022-12-31 15:13:22 +0000 | [diff] [blame] | 343 | " Test zt/zz/zb that they work properly when a long line is above it |
Luuk van Baal | 6f37e53 | 2023-05-09 21:23:54 +0100 | [diff] [blame] | 344 | call term_sendkeys(buf, "zt") |
Bram Moolenaar | db4d88c | 2022-12-31 15:13:22 +0000 | [diff] [blame] | 345 | call VerifyScreenDump(buf, 'Test_smooth_long_11', {}) |
| 346 | call term_sendkeys(buf, "zz") |
| 347 | call VerifyScreenDump(buf, 'Test_smooth_long_12', {}) |
Luuk van Baal | 6f37e53 | 2023-05-09 21:23:54 +0100 | [diff] [blame] | 348 | call term_sendkeys(buf, "zb") |
Bram Moolenaar | db4d88c | 2022-12-31 15:13:22 +0000 | [diff] [blame] | 349 | call VerifyScreenDump(buf, 'Test_smooth_long_13', {}) |
| 350 | |
Yee Cheng Chin | 361895d | 2022-11-19 12:25:16 +0000 | [diff] [blame] | 351 | " Repeat the step and move the cursor down again. |
| 352 | " This time, use a shorter long line that is barely long enough to span more |
| 353 | " than one window. Note that the cursor is at the bottom this time because |
| 354 | " Vim prefers to do so if we are scrolling a few lines only. |
| 355 | call term_sendkeys(buf, ":call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(10)) .. ' end', 'four'])\<CR>") |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 356 | " Currently visible lines were replaced, test that the lines and cursor |
| 357 | " are correctly displayed. |
| 358 | call VerifyScreenDump(buf, 'Test_smooth_long_14', {}) |
Yee Cheng Chin | 361895d | 2022-11-19 12:25:16 +0000 | [diff] [blame] | 359 | call term_sendkeys(buf, "3Gzt") |
| 360 | call term_sendkeys(buf, "j") |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 361 | call VerifyScreenDump(buf, 'Test_smooth_long_15', {}) |
Yee Cheng Chin | 361895d | 2022-11-19 12:25:16 +0000 | [diff] [blame] | 362 | |
| 363 | " Repeat the step but this time start it when the line is smooth-scrolled by |
| 364 | " one line. This tests that the offset calculation is still correct and |
| 365 | " still end up scrolling down to the next line with cursor at bottom of |
| 366 | " screen. |
| 367 | call term_sendkeys(buf, "3Gzt") |
| 368 | call term_sendkeys(buf, "\<C-E>j") |
Luuk van Baal | 5d01f86 | 2023-05-11 19:24:20 +0100 | [diff] [blame] | 369 | call VerifyScreenDump(buf, 'Test_smooth_long_16', {}) |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 370 | |
Bram Moolenaar | 8cf3459 | 2022-10-08 21:13:40 +0100 | [diff] [blame] | 371 | call StopVimInTerminal(buf) |
| 372 | endfunc |
| 373 | |
Bram Moolenaar | 2fbabd2 | 2022-10-12 19:53:38 +0100 | [diff] [blame] | 374 | func Test_smoothscroll_one_long_line() |
| 375 | CheckScreendump |
| 376 | |
| 377 | let lines =<< trim END |
| 378 | vim9script |
| 379 | setline(1, 'with lots of text '->repeat(7)) |
| 380 | set smoothscroll scrolloff=0 |
| 381 | END |
| 382 | call writefile(lines, 'XSmoothOneLong', 'D') |
| 383 | let buf = RunVimInTerminal('-S XSmoothOneLong', #{rows: 6, cols: 40}) |
| 384 | call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {}) |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 385 | |
Bram Moolenaar | 2fbabd2 | 2022-10-12 19:53:38 +0100 | [diff] [blame] | 386 | call term_sendkeys(buf, "\<C-E>") |
| 387 | call VerifyScreenDump(buf, 'Test_smooth_one_long_2', {}) |
| 388 | |
| 389 | call term_sendkeys(buf, "0") |
| 390 | call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {}) |
| 391 | |
| 392 | call StopVimInTerminal(buf) |
| 393 | endfunc |
| 394 | |
Bram Moolenaar | 75ac25b | 2022-11-17 19:00:14 +0000 | [diff] [blame] | 395 | func Test_smoothscroll_long_line_showbreak() |
| 396 | CheckScreendump |
| 397 | |
| 398 | let lines =<< trim END |
| 399 | vim9script |
| 400 | # a line that spans four screen lines |
| 401 | setline(1, 'with lots of text in one line '->repeat(6)) |
| 402 | set smoothscroll scrolloff=0 showbreak=+++\ |
| 403 | END |
| 404 | call writefile(lines, 'XSmoothLongShowbreak', 'D') |
| 405 | let buf = RunVimInTerminal('-S XSmoothLongShowbreak', #{rows: 6, cols: 40}) |
| 406 | call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {}) |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 407 | |
Bram Moolenaar | 75ac25b | 2022-11-17 19:00:14 +0000 | [diff] [blame] | 408 | call term_sendkeys(buf, "\<C-E>") |
| 409 | call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_2', {}) |
| 410 | |
| 411 | call term_sendkeys(buf, "0") |
| 412 | call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {}) |
| 413 | |
| 414 | call StopVimInTerminal(buf) |
| 415 | endfunc |
| 416 | |
zeertzjq | ecb87dd | 2023-06-03 19:45:06 +0100 | [diff] [blame] | 417 | " Check that 'smoothscroll' marker is drawn over double-width char correctly. |
| 418 | " Run with multiple encodings. |
| 419 | func Test_smoothscroll_marker_over_double_width() |
| 420 | " Run this in a separate Vim instance to avoid messing up. |
| 421 | let after =<< trim [CODE] |
| 422 | scriptencoding utf-8 |
| 423 | call setline(1, 'a'->repeat(&columns) .. '口'->repeat(10)) |
| 424 | setlocal smoothscroll |
| 425 | redraw |
| 426 | exe "norm \<C-E>" |
| 427 | redraw |
| 428 | " Check the chars one by one. Don't check the whole line concatenated. |
| 429 | call assert_equal('<', screenstring(1, 1)) |
| 430 | call assert_equal('<', screenstring(1, 2)) |
| 431 | call assert_equal('<', screenstring(1, 3)) |
| 432 | call assert_equal(' ', screenstring(1, 4)) |
| 433 | call assert_equal('口', screenstring(1, 5)) |
| 434 | call assert_equal('口', screenstring(1, 7)) |
| 435 | call assert_equal('口', screenstring(1, 9)) |
| 436 | call assert_equal('口', screenstring(1, 11)) |
| 437 | call assert_equal('口', screenstring(1, 13)) |
| 438 | call assert_equal('口', screenstring(1, 15)) |
| 439 | call writefile(v:errors, 'Xresult') |
| 440 | qall! |
| 441 | [CODE] |
| 442 | |
| 443 | let encodings = ['utf-8', 'cp932', 'cp936', 'cp949', 'cp950'] |
| 444 | if !has('win32') |
| 445 | let encodings += ['euc-jp'] |
| 446 | endif |
| 447 | for enc in encodings |
| 448 | let msg = 'enc=' .. enc |
| 449 | if RunVim([], after, $'--clean --cmd "set encoding={enc}"') |
| 450 | call assert_equal([], readfile('Xresult'), msg) |
| 451 | endif |
| 452 | call delete('Xresult') |
| 453 | endfor |
| 454 | endfunc |
| 455 | |
| 456 | " Same as the test above, but check the text actually shown on screen. |
| 457 | " Only run with UTF-8 encoding. |
| 458 | func Test_smoothscroll_marker_over_double_width_dump() |
| 459 | CheckScreendump |
| 460 | |
| 461 | let lines =<< trim END |
| 462 | call setline(1, 'a'->repeat(&columns) .. '口'->repeat(10)) |
| 463 | setlocal smoothscroll |
| 464 | END |
| 465 | call writefile(lines, 'XSmoothMarkerOverDoubleWidth', 'D') |
| 466 | let buf = RunVimInTerminal('-S XSmoothMarkerOverDoubleWidth', #{rows: 6, cols: 40}) |
| 467 | call VerifyScreenDump(buf, 'Test_smooth_marker_over_double_width_1', {}) |
| 468 | |
| 469 | call term_sendkeys(buf, "\<C-E>") |
| 470 | call VerifyScreenDump(buf, 'Test_smooth_marker_over_double_width_2', {}) |
| 471 | |
| 472 | call StopVimInTerminal(buf) |
| 473 | endfunc |
| 474 | |
Bram Moolenaar | 1b73edd | 2022-12-03 11:51:54 +0000 | [diff] [blame] | 475 | func s:check_col_calc(win_col, win_line, buf_col) |
| 476 | call assert_equal(a:win_col, wincol()) |
| 477 | call assert_equal(a:win_line, winline()) |
| 478 | call assert_equal(a:buf_col, col('.')) |
| 479 | endfunc |
| 480 | |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 481 | " Test that if the current cursor is on a smooth scrolled line, we correctly |
| 482 | " reposition it. Also check that we don't miscalculate the values by checking |
| 483 | " the consistency between wincol() and col('.') as they are calculated |
| 484 | " separately in code. |
| 485 | func Test_smoothscroll_cursor_position() |
| 486 | call NewWindow(10, 20) |
| 487 | setl smoothscroll wrap |
| 488 | call setline(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
| 489 | |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 490 | call s:check_col_calc(1, 1, 1) |
| 491 | exe "normal \<C-E>" |
| 492 | |
| 493 | " Move down another line to avoid blocking the <<< display |
| 494 | call s:check_col_calc(1, 2, 41) |
| 495 | exe "normal \<C-Y>" |
| 496 | call s:check_col_calc(1, 3, 41) |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 497 | |
Luuk van Baal | 8667a56 | 2023-05-12 15:47:25 +0100 | [diff] [blame] | 498 | " Test "g0/g<Home>" |
| 499 | exe "normal gg\<C-E>" |
| 500 | norm $gkg0 |
| 501 | call s:check_col_calc(1, 2, 21) |
| 502 | |
| 503 | " Test moving the cursor behind the <<< display with 'virtualedit' |
| 504 | set virtualedit=all |
Luuk van Baal | 24b62ec | 2023-05-13 14:12:15 +0100 | [diff] [blame] | 505 | exe "normal \<C-E>3lgkh" |
Luuk van Baal | 8667a56 | 2023-05-12 15:47:25 +0100 | [diff] [blame] | 506 | call s:check_col_calc(3, 2, 23) |
| 507 | set virtualedit& |
| 508 | |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 509 | normal gg3l |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 510 | exe "normal \<C-E>" |
| 511 | |
| 512 | " 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] | 513 | call s:check_col_calc(4, 1, 24) |
| 514 | exe "normal \<C-Y>" |
| 515 | call s:check_col_calc(4, 2, 24) |
| 516 | normal ggg$ |
| 517 | exe "normal \<C-E>" |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 518 | call s:check_col_calc(20, 1, 40) |
| 519 | exe "normal \<C-Y>" |
| 520 | call s:check_col_calc(20, 2, 40) |
| 521 | normal gg |
| 522 | |
| 523 | " Test number, where we have indented lines |
| 524 | setl number |
| 525 | call s:check_col_calc(5, 1, 1) |
| 526 | exe "normal \<C-E>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 527 | |
| 528 | " Move down only 1 line when the <<< display is on the number column |
| 529 | call s:check_col_calc(5, 1, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 530 | exe "normal \<C-Y>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 531 | call s:check_col_calc(5, 2, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 532 | normal ggg$ |
| 533 | exe "normal \<C-E>" |
| 534 | call s:check_col_calc(20, 1, 32) |
| 535 | exe "normal \<C-Y>" |
| 536 | call s:check_col_calc(20, 2, 32) |
| 537 | normal gg |
| 538 | |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 539 | setl numberwidth=1 |
| 540 | |
| 541 | " Move down another line when numberwidth is too short to cover the whole |
| 542 | " <<< display |
| 543 | call s:check_col_calc(3, 1, 1) |
| 544 | exe "normal \<C-E>" |
| 545 | call s:check_col_calc(3, 2, 37) |
| 546 | exe "normal \<C-Y>" |
| 547 | call s:check_col_calc(3, 3, 37) |
| 548 | normal ggl |
| 549 | |
| 550 | " Only move 1 line down when we are just past the <<< display |
| 551 | call s:check_col_calc(4, 1, 2) |
| 552 | exe "normal \<C-E>" |
| 553 | call s:check_col_calc(4, 1, 20) |
| 554 | exe "normal \<C-Y>" |
| 555 | call s:check_col_calc(4, 2, 20) |
| 556 | normal gg |
| 557 | setl numberwidth& |
| 558 | |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 559 | " Test number + showbreak, so test that the additional indentation works |
| 560 | setl number showbreak=+++ |
| 561 | call s:check_col_calc(5, 1, 1) |
| 562 | exe "normal \<C-E>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 563 | call s:check_col_calc(8, 1, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 564 | exe "normal \<C-Y>" |
Yee Cheng Chin | 81ba26e | 2022-11-18 12:52:50 +0000 | [diff] [blame] | 565 | call s:check_col_calc(8, 2, 17) |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 566 | normal gg |
| 567 | |
| 568 | " Test number + cpo+=n mode, where wrapped lines aren't indented |
| 569 | setl number cpo+=n showbreak= |
| 570 | call s:check_col_calc(5, 1, 1) |
| 571 | exe "normal \<C-E>" |
| 572 | call s:check_col_calc(1, 2, 37) |
| 573 | exe "normal \<C-Y>" |
| 574 | call s:check_col_calc(1, 3, 37) |
| 575 | normal gg |
| 576 | |
Luuk van Baal | 24b62ec | 2023-05-13 14:12:15 +0100 | [diff] [blame] | 577 | " Test list + listchars "precedes", where there is always 1 overlap |
| 578 | " regardless of number and cpo-=n. |
| 579 | setl number list listchars=precedes:< cpo-=n |
| 580 | call s:check_col_calc(5, 1, 1) |
Luuk van Baal | 798fa76 | 2023-05-15 18:17:43 +0100 | [diff] [blame] | 581 | exe "normal 3|\<C-E>h" |
Luuk van Baal | 24b62ec | 2023-05-13 14:12:15 +0100 | [diff] [blame] | 582 | call s:check_col_calc(6, 1, 18) |
| 583 | norm h |
| 584 | call s:check_col_calc(5, 2, 17) |
| 585 | normal gg |
| 586 | |
Bram Moolenaar | 1b73edd | 2022-12-03 11:51:54 +0000 | [diff] [blame] | 587 | bwipe! |
Yee Cheng Chin | 01ee52b | 2022-11-17 12:41:42 +0000 | [diff] [blame] | 588 | endfunc |
| 589 | |
Bram Moolenaar | 1b73edd | 2022-12-03 11:51:54 +0000 | [diff] [blame] | 590 | func Test_smoothscroll_cursor_scrolloff() |
| 591 | call NewWindow(10, 20) |
| 592 | setl smoothscroll wrap |
| 593 | setl scrolloff=3 |
Bram Moolenaar | 94722c5 | 2023-01-28 19:19:03 +0000 | [diff] [blame] | 594 | |
Bram Moolenaar | 1b73edd | 2022-12-03 11:51:54 +0000 | [diff] [blame] | 595 | " 120 chars are 6 screen lines |
| 596 | call setline(1, "abcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRST") |
| 597 | call setline(2, "below") |
| 598 | |
| 599 | call s:check_col_calc(1, 1, 1) |
| 600 | |
| 601 | " CTRL-E shows "<<<DEFG...", cursor move four lines down |
| 602 | exe "normal \<C-E>" |
| 603 | call s:check_col_calc(1, 4, 81) |
| 604 | |
| 605 | " cursor on start of second line, "gk" moves into first line, skipcol doesn't |
| 606 | " change |
| 607 | exe "normal G0gk" |
| 608 | call s:check_col_calc(1, 5, 101) |
| 609 | |
| 610 | " move cursor left one window width worth, scrolls one screen line |
| 611 | exe "normal 20h" |
| 612 | call s:check_col_calc(1, 5, 81) |
| 613 | |
| 614 | " move cursor left one window width worth, scrolls one screen line |
| 615 | exe "normal 20h" |
| 616 | call s:check_col_calc(1, 4, 61) |
| 617 | |
Bram Moolenaar | b21b8e9 | 2022-12-03 18:35:07 +0000 | [diff] [blame] | 618 | " cursor on last line, "gk" should not cause a scroll |
| 619 | set scrolloff=0 |
| 620 | normal G0 |
| 621 | call s:check_col_calc(1, 7, 1) |
| 622 | normal gk |
| 623 | call s:check_col_calc(1, 6, 101) |
| 624 | |
Bram Moolenaar | 1b73edd | 2022-12-03 11:51:54 +0000 | [diff] [blame] | 625 | bwipe! |
| 626 | endfunc |
| 627 | |
| 628 | |
Yee Cheng Chin | e6392b1 | 2022-11-19 14:31:08 +0000 | [diff] [blame] | 629 | " Test that mouse picking is still accurate when we have smooth scrolled lines |
| 630 | func Test_smoothscroll_mouse_pos() |
| 631 | CheckNotGui |
| 632 | CheckUnix |
| 633 | |
| 634 | let save_mouse = &mouse |
| 635 | let save_term = &term |
| 636 | let save_ttymouse = &ttymouse |
| 637 | set mouse=a term=xterm ttymouse=xterm2 |
| 638 | |
| 639 | call NewWindow(10, 20) |
| 640 | setl smoothscroll wrap |
| 641 | " First line will wrap to 3 physical lines. 2nd/3rd lines are short lines. |
| 642 | call setline(1, ["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "line 2", "line 3"]) |
| 643 | |
| 644 | func s:check_mouse_click(row, col, buf_row, buf_col) |
| 645 | call MouseLeftClick(a:row, a:col) |
| 646 | |
| 647 | call assert_equal(a:col, wincol()) |
| 648 | call assert_equal(a:row, winline()) |
| 649 | call assert_equal(a:buf_row, line('.')) |
| 650 | call assert_equal(a:buf_col, col('.')) |
| 651 | endfunc |
| 652 | |
| 653 | " Check that clicking without scroll works first. |
| 654 | call s:check_mouse_click(3, 5, 1, 45) |
| 655 | call s:check_mouse_click(4, 1, 2, 1) |
| 656 | call s:check_mouse_click(4, 6, 2, 6) |
| 657 | call s:check_mouse_click(5, 1, 3, 1) |
| 658 | call s:check_mouse_click(5, 6, 3, 6) |
| 659 | |
| 660 | " Smooth scroll, and checks that this didn't mess up mouse clicking |
| 661 | exe "normal \<C-E>" |
| 662 | call s:check_mouse_click(2, 5, 1, 45) |
| 663 | call s:check_mouse_click(3, 1, 2, 1) |
| 664 | call s:check_mouse_click(3, 6, 2, 6) |
| 665 | call s:check_mouse_click(4, 1, 3, 1) |
| 666 | call s:check_mouse_click(4, 6, 3, 6) |
| 667 | |
| 668 | exe "normal \<C-E>" |
| 669 | call s:check_mouse_click(1, 5, 1, 45) |
| 670 | call s:check_mouse_click(2, 1, 2, 1) |
| 671 | call s:check_mouse_click(2, 6, 2, 6) |
| 672 | call s:check_mouse_click(3, 1, 3, 1) |
| 673 | call s:check_mouse_click(3, 6, 3, 6) |
| 674 | |
| 675 | " Make a new first line 11 physical lines tall so it's taller than window |
| 676 | " height, to test overflow calculations with really long lines wrapping. |
| 677 | normal gg |
| 678 | call setline(1, "12345678901234567890"->repeat(11)) |
| 679 | exe "normal 6\<C-E>" |
| 680 | call s:check_mouse_click(5, 1, 1, 201) |
| 681 | call s:check_mouse_click(6, 1, 2, 1) |
| 682 | call s:check_mouse_click(7, 1, 3, 1) |
| 683 | |
| 684 | let &mouse = save_mouse |
| 685 | let &term = save_term |
| 686 | let &ttymouse = save_ttymouse |
| 687 | endfunc |
| 688 | |
Bram Moolenaar | 870219c | 2023-01-26 14:14:43 +0000 | [diff] [blame] | 689 | " this was dividing by zero |
Luuk van Baal | c8502f9 | 2023-05-06 12:40:15 +0100 | [diff] [blame] | 690 | func Test_smoothscroll_zero_width() |
Bram Moolenaar | 870219c | 2023-01-26 14:14:43 +0000 | [diff] [blame] | 691 | CheckScreendump |
| 692 | |
| 693 | let lines =<< trim END |
| 694 | winsize 0 0 |
| 695 | vsplit |
| 696 | vsplit |
| 697 | vsplit |
| 698 | vsplit |
| 699 | vsplit |
| 700 | sil norm H |
| 701 | set wrap |
| 702 | set smoothscroll |
| 703 | set number |
| 704 | END |
| 705 | call writefile(lines, 'XSmoothScrollZero', 'D') |
| 706 | let buf = RunVimInTerminal('-u NONE -i NONE -n -m -X -Z -e -s -S XSmoothScrollZero', #{rows: 6, cols: 60, wait_for_ruler: 0}) |
Bram Moolenaar | 870219c | 2023-01-26 14:14:43 +0000 | [diff] [blame] | 707 | call VerifyScreenDump(buf, 'Test_smoothscroll_zero_1', {}) |
| 708 | |
| 709 | call term_sendkeys(buf, ":sil norm \<C-V>\<C-W>\<C-V>\<C-N>\<CR>") |
| 710 | call VerifyScreenDump(buf, 'Test_smoothscroll_zero_2', {}) |
| 711 | |
| 712 | call StopVimInTerminal(buf) |
| 713 | endfunc |
| 714 | |
Luuk van Baal | c8502f9 | 2023-05-06 12:40:15 +0100 | [diff] [blame] | 715 | " this was unnecessarily inserting lines |
| 716 | func Test_smoothscroll_ins_lines() |
| 717 | CheckScreendump |
| 718 | |
| 719 | let lines =<< trim END |
| 720 | set wrap |
| 721 | set smoothscroll |
| 722 | set scrolloff=0 |
| 723 | set conceallevel=2 |
| 724 | call setline(1, [ |
| 725 | \'line one' .. 'with lots of text in one line '->repeat(2), |
| 726 | \'line two', |
| 727 | \'line three', |
| 728 | \'line four', |
| 729 | \'line five' |
| 730 | \]) |
| 731 | END |
| 732 | call writefile(lines, 'XSmoothScrollInsLines', 'D') |
| 733 | let buf = RunVimInTerminal('-S XSmoothScrollInsLines', #{rows: 6, cols: 40}) |
| 734 | |
| 735 | call term_sendkeys(buf, "\<C-E>gjgk") |
| 736 | call VerifyScreenDump(buf, 'Test_smooth_ins_lines', {}) |
| 737 | |
| 738 | call StopVimInTerminal(buf) |
| 739 | endfunc |
Bram Moolenaar | f6196f4 | 2022-10-02 21:29:55 +0100 | [diff] [blame] | 740 | |
Luuk van Baal | 3ce8c38 | 2023-05-08 15:51:14 +0100 | [diff] [blame] | 741 | " this placed the cursor in the command line |
| 742 | func Test_smoothscroll_cursormoved_line() |
| 743 | CheckScreendump |
| 744 | |
| 745 | let lines =<< trim END |
| 746 | set smoothscroll |
| 747 | call setline(1, [ |
| 748 | \'', |
| 749 | \'_'->repeat(&lines * &columns), |
| 750 | \(('_')->repeat(&columns - 2) .. 'xxx')->repeat(2) |
| 751 | \]) |
| 752 | autocmd CursorMoved * eval [line('w0'), line('w$')] |
| 753 | call search('xxx') |
| 754 | END |
| 755 | call writefile(lines, 'XSmoothCursorMovedLine', 'D') |
| 756 | let buf = RunVimInTerminal('-S XSmoothCursorMovedLine', #{rows: 6}) |
| 757 | |
| 758 | call VerifyScreenDump(buf, 'Test_smooth_cursormoved_line', {}) |
| 759 | |
| 760 | call StopVimInTerminal(buf) |
| 761 | endfunc |
| 762 | |
| 763 | func Test_smoothscroll_eob() |
| 764 | CheckScreendump |
| 765 | |
| 766 | let lines =<< trim END |
| 767 | set smoothscroll |
| 768 | call setline(1, ['']->repeat(100)) |
| 769 | norm G |
| 770 | END |
| 771 | call writefile(lines, 'XSmoothEob', 'D') |
| 772 | let buf = RunVimInTerminal('-S XSmoothEob', #{rows: 10}) |
| 773 | |
| 774 | " does not scroll halfway when scrolling to end of buffer |
| 775 | call VerifyScreenDump(buf, 'Test_smooth_eob_1', {}) |
| 776 | |
| 777 | " cursor is not placed below window |
| 778 | call term_sendkeys(buf, ":call setline(92, 'a'->repeat(100))\<CR>\<C-B>G") |
| 779 | call VerifyScreenDump(buf, 'Test_smooth_eob_2', {}) |
| 780 | |
| 781 | call StopVimInTerminal(buf) |
| 782 | endfunc |
| 783 | |
Luuk van Baal | d49f646 | 2023-05-19 14:04:47 +0100 | [diff] [blame] | 784 | " skipcol should not reset when doing incremental search on the same word |
| 785 | func Test_smoothscroll_incsearch() |
| 786 | CheckScreendump |
| 787 | |
| 788 | let lines =<< trim END |
| 789 | set smoothscroll number scrolloff=0 incsearch |
| 790 | call setline(1, repeat([''], 20)) |
| 791 | call setline(11, repeat('a', 100)) |
| 792 | call setline(14, 'bbbb') |
| 793 | END |
| 794 | call writefile(lines, 'XSmoothIncsearch', 'D') |
zeertzjq | 3c80227 | 2023-06-03 22:08:33 +0100 | [diff] [blame] | 795 | let buf = RunVimInTerminal('-S XSmoothIncsearch', #{rows: 8, cols: 40}) |
Luuk van Baal | d49f646 | 2023-05-19 14:04:47 +0100 | [diff] [blame] | 796 | |
| 797 | call term_sendkeys(buf, "/b") |
| 798 | call VerifyScreenDump(buf, 'Test_smooth_incsearch_1', {}) |
| 799 | call term_sendkeys(buf, "b") |
| 800 | call VerifyScreenDump(buf, 'Test_smooth_incsearch_2', {}) |
| 801 | call term_sendkeys(buf, "b") |
| 802 | call VerifyScreenDump(buf, 'Test_smooth_incsearch_3', {}) |
| 803 | call term_sendkeys(buf, "b") |
| 804 | call VerifyScreenDump(buf, 'Test_smooth_incsearch_4', {}) |
| 805 | call term_sendkeys(buf, "\<CR>") |
| 806 | |
| 807 | call StopVimInTerminal(buf) |
| 808 | endfunc |
| 809 | |
zeertzjq | 3c80227 | 2023-06-03 22:08:33 +0100 | [diff] [blame] | 810 | " Test scrolling multiple lines and stopping at non-zero skipcol. |
| 811 | func Test_smoothscroll_multi_skipcol() |
| 812 | CheckScreendump |
| 813 | |
| 814 | let lines =<< trim END |
| 815 | setlocal cursorline scrolloff=0 smoothscroll |
zeertzjq | d9a92dc | 2023-06-05 18:41:35 +0100 | [diff] [blame] | 816 | call setline(1, repeat([''], 8)) |
zeertzjq | 3c80227 | 2023-06-03 22:08:33 +0100 | [diff] [blame] | 817 | call setline(3, repeat('a', 50)) |
zeertzjq | d9a92dc | 2023-06-05 18:41:35 +0100 | [diff] [blame] | 818 | call setline(4, repeat('a', 50)) |
| 819 | call setline(7, 'bbb') |
| 820 | call setline(8, 'ccc') |
zeertzjq | 3c80227 | 2023-06-03 22:08:33 +0100 | [diff] [blame] | 821 | redraw |
| 822 | END |
| 823 | call writefile(lines, 'XSmoothMultiSkipcol', 'D') |
| 824 | let buf = RunVimInTerminal('-S XSmoothMultiSkipcol', #{rows: 10, cols: 40}) |
| 825 | call VerifyScreenDump(buf, 'Test_smooth_multi_skipcol_1', {}) |
| 826 | |
| 827 | call term_sendkeys(buf, "3\<C-E>") |
| 828 | call VerifyScreenDump(buf, 'Test_smooth_multi_skipcol_2', {}) |
| 829 | |
zeertzjq | d9a92dc | 2023-06-05 18:41:35 +0100 | [diff] [blame] | 830 | call term_sendkeys(buf, "2\<C-E>") |
| 831 | call VerifyScreenDump(buf, 'Test_smooth_multi_skipcol_3', {}) |
| 832 | |
zeertzjq | 3c80227 | 2023-06-03 22:08:33 +0100 | [diff] [blame] | 833 | call StopVimInTerminal(buf) |
| 834 | endfunc |
| 835 | |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 836 | " vim: shiftwidth=2 sts=2 expandtab |