comparison src/testdir/test_scroll_opt.vim @ 31329:5c83140aafc9 v9.0.0998

patch 9.0.0998: "gk" may reset skipcol when not needed Commit: https://github.com/vim/vim/commit/1b73edd9ee40aec400f3611f59823cec5fd1c489 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 3 11:51:54 2022 +0000 patch 9.0.0998: "gk" may reset skipcol when not needed Problem: "gk" may reset skipcol when not needed. Solution: Only reset skipcol if the cursor column is less.
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Dec 2022 13:00:04 +0100
parents 7e48ddb8b079
children bfbcc148da58
comparison
equal deleted inserted replaced
31328:aeffee6a601a 31329:5c83140aafc9
357 call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {}) 357 call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {})
358 358
359 call StopVimInTerminal(buf) 359 call StopVimInTerminal(buf)
360 endfunc 360 endfunc
361 361
362 func s:check_col_calc(win_col, win_line, buf_col)
363 call assert_equal(a:win_col, wincol())
364 call assert_equal(a:win_line, winline())
365 call assert_equal(a:buf_col, col('.'))
366 endfunc
367
362 " Test that if the current cursor is on a smooth scrolled line, we correctly 368 " Test that if the current cursor is on a smooth scrolled line, we correctly
363 " reposition it. Also check that we don't miscalculate the values by checking 369 " reposition it. Also check that we don't miscalculate the values by checking
364 " the consistency between wincol() and col('.') as they are calculated 370 " the consistency between wincol() and col('.') as they are calculated
365 " separately in code. 371 " separately in code.
366 func Test_smoothscroll_cursor_position() 372 func Test_smoothscroll_cursor_position()
367 call NewWindow(10, 20) 373 call NewWindow(10, 20)
368 setl smoothscroll wrap 374 setl smoothscroll wrap
369 call setline(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 375 call setline(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
370 376
371 func s:check_col_calc(win_col, win_line, buf_col)
372 call assert_equal(a:win_col, wincol())
373 call assert_equal(a:win_line, winline())
374 call assert_equal(a:buf_col, col('.'))
375 endfunc
376
377 call s:check_col_calc(1, 1, 1) 377 call s:check_col_calc(1, 1, 1)
378 exe "normal \<C-E>" 378 exe "normal \<C-E>"
379 379
380 " Move down another line to avoid blocking the <<< display 380 " Move down another line to avoid blocking the <<< display
381 call s:check_col_calc(1, 2, 41) 381 call s:check_col_calc(1, 2, 41)
448 call s:check_col_calc(1, 2, 37) 448 call s:check_col_calc(1, 2, 37)
449 exe "normal \<C-Y>" 449 exe "normal \<C-Y>"
450 call s:check_col_calc(1, 3, 37) 450 call s:check_col_calc(1, 3, 37)
451 normal gg 451 normal gg
452 452
453 bwipeout! 453 bwipe!
454 endfunc 454 endfunc
455
456 func Test_smoothscroll_cursor_scrolloff()
457 call NewWindow(10, 20)
458 setl smoothscroll wrap
459 setl scrolloff=3
460
461 " 120 chars are 6 screen lines
462 call setline(1, "abcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRST")
463 call setline(2, "below")
464
465 call s:check_col_calc(1, 1, 1)
466
467 " CTRL-E shows "<<<DEFG...", cursor move four lines down
468 exe "normal \<C-E>"
469 call s:check_col_calc(1, 4, 81)
470
471 " cursor on start of second line, "gk" moves into first line, skipcol doesn't
472 " change
473 exe "normal G0gk"
474 call s:check_col_calc(1, 5, 101)
475
476 " move cursor left one window width worth, scrolls one screen line
477 exe "normal 20h"
478 call s:check_col_calc(1, 5, 81)
479
480 " move cursor left one window width worth, scrolls one screen line
481 exe "normal 20h"
482 call s:check_col_calc(1, 4, 61)
483
484 bwipe!
485 endfunc
486
455 487
456 " Test that mouse picking is still accurate when we have smooth scrolled lines 488 " Test that mouse picking is still accurate when we have smooth scrolled lines
457 func Test_smoothscroll_mouse_pos() 489 func Test_smoothscroll_mouse_pos()
458 CheckNotGui 490 CheckNotGui
459 CheckUnix 491 CheckUnix