Mercurial > vim
comparison src/testdir/test_scroll_opt.vim @ 34815:8e38ceda0822 v9.1.0280
patch 9.1.0280: several issues with 'smoothscroll' support
Commit: https://github.com/vim/vim/commit/9148ba8a46baa3934c44164989cdcdec5d01d9e3
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Mon Apr 8 22:27:41 2024 +0200
patch 9.1.0280: several issues with 'smoothscroll' support
Problem: Logic to make sure cursor is in visible part of the screen after
scrolling the text with 'smoothscroll' is scattered, asymmetric
and contains bugs.
Solution: Adjust and create helper function for 'smoothscroll' cursor logic.
(Luuk van Baal)
closes: #14410
Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 08 Apr 2024 22:45:03 +0200 |
parents | be09936c20c7 |
children | fa2084ba5138 |
comparison
equal
deleted
inserted
replaced
34814:6ff5ddfde885 | 34815:8e38ceda0822 |
---|---|
1018 call assert_equal(0, winsaveview().skipcol) | 1018 call assert_equal(0, winsaveview().skipcol) |
1019 | 1019 |
1020 " Half-page scrolling does not go beyond end of buffer and moves the cursor. | 1020 " Half-page scrolling does not go beyond end of buffer and moves the cursor. |
1021 " Even with 'nostartofline', the correct amount of lines is scrolled. | 1021 " Even with 'nostartofline', the correct amount of lines is scrolled. |
1022 setl nostartofline | 1022 setl nostartofline |
1023 exe "norm! 0\<C-D>" | 1023 exe "norm! 15|\<C-D>" |
1024 call assert_equal(200, winsaveview().skipcol) | 1024 call assert_equal(200, winsaveview().skipcol) |
1025 call assert_equal(204, col('.')) | 1025 call assert_equal(215, col('.')) |
1026 exe "norm! \<C-D>" | 1026 exe "norm! \<C-D>" |
1027 call assert_equal(400, winsaveview().skipcol) | 1027 call assert_equal(400, winsaveview().skipcol) |
1028 call assert_equal(404, col('.')) | 1028 call assert_equal(415, col('.')) |
1029 exe "norm! \<C-D>" | 1029 exe "norm! \<C-D>" |
1030 call assert_equal(520, winsaveview().skipcol) | 1030 call assert_equal(520, winsaveview().skipcol) |
1031 call assert_equal(601, col('.')) | 1031 call assert_equal(535, col('.')) |
1032 exe "norm! \<C-D>" | 1032 exe "norm! \<C-D>" |
1033 call assert_equal(520, winsaveview().skipcol) | 1033 call assert_equal(520, winsaveview().skipcol) |
1034 call assert_equal(801, col('.')) | 1034 call assert_equal(735, col('.')) |
1035 exe "norm! \<C-D>" | |
1036 call assert_equal(520, winsaveview().skipcol) | |
1037 call assert_equal(895, col('.')) | |
1035 exe "norm! \<C-U>" | 1038 exe "norm! \<C-U>" |
1036 call assert_equal(520, winsaveview().skipcol) | 1039 call assert_equal(320, winsaveview().skipcol) |
1037 call assert_equal(601, col('.')) | 1040 call assert_equal(695, col('.')) |
1038 exe "norm! \<C-U>" | 1041 exe "norm! \<C-U>" |
1039 call assert_equal(400, winsaveview().skipcol) | 1042 call assert_equal(120, winsaveview().skipcol) |
1040 call assert_equal(404, col('.')) | 1043 call assert_equal(495, col('.')) |
1041 exe "norm! \<C-U>" | |
1042 call assert_equal(200, winsaveview().skipcol) | |
1043 call assert_equal(204, col('.')) | |
1044 exe "norm! \<C-U>" | 1044 exe "norm! \<C-U>" |
1045 call assert_equal(0, winsaveview().skipcol) | 1045 call assert_equal(0, winsaveview().skipcol) |
1046 call assert_equal(40, col('.')) | 1046 call assert_equal(375, col('.')) |
1047 exe "norm! \<C-U>" | |
1048 call assert_equal(0, winsaveview().skipcol) | |
1049 call assert_equal(175, col('.')) | |
1050 exe "norm! \<C-U>" | |
1051 call assert_equal(0, winsaveview().skipcol) | |
1052 call assert_equal(15, col('.')) | |
1047 | 1053 |
1048 bwipe! | 1054 bwipe! |
1049 endfunc | 1055 endfunc |
1050 | 1056 |
1051 func Test_smoothscroll_next_topline() | 1057 func Test_smoothscroll_next_topline() |
1069 " Cursor in correct place when not in the first screenline of a buffer line. | 1075 " Cursor in correct place when not in the first screenline of a buffer line. |
1070 exe "norm! gg4gj20\<C-D>\<C-D>" | 1076 exe "norm! gg4gj20\<C-D>\<C-D>" |
1071 redraw | 1077 redraw |
1072 call assert_equal(2, line('w0')) | 1078 call assert_equal(2, line('w0')) |
1073 | 1079 |
1080 " Cursor does not end up above topline, adjusting topline later. | |
1081 setlocal nu cpo+=n | |
1082 exe "norm! G$g013\<C-Y>" | |
1083 redraw | |
1084 call assert_equal(2, line('.')) | |
1085 call assert_equal(0, winsaveview().skipcol) | |
1086 | |
1087 set cpo-=n | |
1074 bwipe! | 1088 bwipe! |
1075 endfunc | 1089 endfunc |
1076 | 1090 |
1077 func Test_smoothscroll_long_line_zb() | 1091 func Test_smoothscroll_long_line_zb() |
1078 call NewWindow(10, 40) | 1092 call NewWindow(10, 40) |