comparison src/testdir/test_scroll_opt.vim @ 34761:b20609f4ab37 v9.1.0258

patch 9.1.0258: half-page scrolling broke backward compatibility Commit: https://github.com/vim/vim/commit/cb204e688e5c9d56a78b621ef27c35d91860cb09 Author: Luuk van Baal <luukvbaal@gmail.com> Date: Tue Apr 2 20:49:45 2024 +0200 patch 9.1.0258: half-page scrolling broke backward compatibility Problem: Support for 'smoothscroll' in (half-)page scrolling broke backward compatibility and can be made to work better. (after v9.1.215) Solution: Restore the previous cursor and end-of-buffer behavior for half-page scrolling and improve 'smoothscroll' support. (Luuk van Baal) fixes: #14338 closes: #14377 Signed-off-by: Luuk van Baal <luukvbaal@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 02 Apr 2024 21:00:06 +0200
parents 5569220366ee
children be09936c20c7
comparison
equal deleted inserted replaced
34760:d14cb0d9988c 34761:b20609f4ab37
550 call s:check_col_calc(1, 3, 41) 550 call s:check_col_calc(1, 3, 41)
551 551
552 " Test "g0/g<Home>" 552 " Test "g0/g<Home>"
553 exe "normal gg\<C-E>" 553 exe "normal gg\<C-E>"
554 norm $gkg0 554 norm $gkg0
555 call s:check_col_calc(1, 2, 21) 555 call s:check_col_calc(4, 1, 24)
556 556
557 " Test moving the cursor behind the <<< display with 'virtualedit' 557 " Test moving the cursor behind the <<< display with 'virtualedit'
558 set virtualedit=all 558 set virtualedit=all
559 exe "normal \<C-E>3lgkh" 559 exe "normal \<C-E>gkh"
560 call s:check_col_calc(3, 2, 23) 560 call s:check_col_calc(3, 2, 23)
561 set virtualedit& 561 set virtualedit&
562 562
563 normal gg3l 563 normal gg3l
564 exe "normal \<C-E>" 564 exe "normal \<C-E>"
1015 exe "norm! \<C-B>" 1015 exe "norm! \<C-B>"
1016 call assert_equal(80, winsaveview().skipcol) 1016 call assert_equal(80, winsaveview().skipcol)
1017 exe "norm! \<C-B>" 1017 exe "norm! \<C-B>"
1018 call assert_equal(0, winsaveview().skipcol) 1018 call assert_equal(0, winsaveview().skipcol)
1019 1019
1020 exe "norm! \<C-D>" 1020 " Half-page scrolling does not go beyond end of buffer and moves the cursor.
1021 exe "norm! 0\<C-D>"
1021 call assert_equal(200, winsaveview().skipcol) 1022 call assert_equal(200, winsaveview().skipcol)
1023 call assert_equal(204, col('.'))
1022 exe "norm! \<C-D>" 1024 exe "norm! \<C-D>"
1023 call assert_equal(400, winsaveview().skipcol) 1025 call assert_equal(400, winsaveview().skipcol)
1026 call assert_equal(404, col('.'))
1024 exe "norm! \<C-D>" 1027 exe "norm! \<C-D>"
1025 call assert_equal(600, winsaveview().skipcol) 1028 call assert_equal(520, winsaveview().skipcol)
1029 call assert_equal(601, col('.'))
1026 exe "norm! \<C-D>" 1030 exe "norm! \<C-D>"
1027 call assert_equal(800, winsaveview().skipcol) 1031 call assert_equal(520, winsaveview().skipcol)
1028 exe "norm! \<C-D>" 1032 call assert_equal(801, col('.'))
1029 call assert_equal(880, winsaveview().skipcol)
1030 exe "norm! \<C-U>" 1033 exe "norm! \<C-U>"
1031 call assert_equal(680, winsaveview().skipcol) 1034 call assert_equal(520, winsaveview().skipcol)
1035 call assert_equal(601, col('.'))
1032 exe "norm! \<C-U>" 1036 exe "norm! \<C-U>"
1033 call assert_equal(480, winsaveview().skipcol) 1037 call assert_equal(400, winsaveview().skipcol)
1038 call assert_equal(404, col('.'))
1034 exe "norm! \<C-U>" 1039 exe "norm! \<C-U>"
1035 call assert_equal(280, winsaveview().skipcol) 1040 call assert_equal(200, winsaveview().skipcol)
1036 exe "norm! \<C-U>" 1041 call assert_equal(204, col('.'))
1037 call assert_equal(80, winsaveview().skipcol)
1038 exe "norm! \<C-U>" 1042 exe "norm! \<C-U>"
1039 call assert_equal(0, winsaveview().skipcol) 1043 call assert_equal(0, winsaveview().skipcol)
1044 call assert_equal(1, col('.'))
1040 1045
1041 bwipe! 1046 bwipe!
1042 endfunc 1047 endfunc
1043 1048
1049 func Test_smoothscroll_next_topline()
1050 call NewWindow(10, 40)
1051 setlocal smoothscroll
1052 call setline(1, ['abcde '->repeat(150)]->repeat(2))
1053
1054 " Scrolling a screenline that causes the cursor to move to the next buffer
1055 " line should not skip part of that line to bring the cursor into view.
1056 exe "norm! 22\<C-E>"
1057 call assert_equal(880, winsaveview().skipcol)
1058 exe "norm! \<C-E>"
1059 redraw
1060 call assert_equal(0, winsaveview().skipcol)
1061
1062 " Cursor in correct place when not in the first screenline of a buffer line.
1063 exe "norm! gg4gj20\<C-D>\<C-D>"
1064 redraw
1065 call assert_equal(2, line('w0'))
1066
1067 bwipe!
1068 endfunc
1069
1070 func Test_smoothscroll_long_line_zb()
1071 call NewWindow(10, 40)
1072 call setline(1, 'abcde '->repeat(150))
1073
1074 " Also works without 'smoothscroll' when last line of buffer doesn't fit.
1075 " Used to set topline to buffer line count plus one, causing an empty screen.
1076 norm zb
1077 redraw
1078 call assert_equal(1, winsaveview().topline)
1079
1080 " Moving cursor to bottom works on line that doesn't fit with 'smoothscroll'.
1081 " Skipcol was adjusted later for cursor being on not visible part of line.
1082 setlocal smoothscroll
1083 norm zb
1084 redraw
1085 call assert_equal(520, winsaveview().skipcol)
1086
1087 bwipe!
1088 endfunc
1089
1044 " vim: shiftwidth=2 sts=2 expandtab 1090 " vim: shiftwidth=2 sts=2 expandtab