diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-15 18:17:43 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-05-15 18:17:43 +0100 |
commit | 798fa76dbf737f855e47b10bf326453866b429ab (patch) | |
tree | 3194248222b2d67365b2349c796ac9e262c497b6 | |
parent | f741e3ec1fcecc8f23f1b37415dc3e80a31d157e (diff) | |
download | vim-git-798fa76dbf737f855e47b10bf326453866b429ab.tar.gz |
patch 9.0.1561: display wrong when moving cursor to above the top linev9.0.1561
Problem: Display wrong when moving cursor to above the top line and
'smoothscroll' is set.
Solution: Call adjust_skipcol() in more places and make it work better.
(Luuk van Baal, closes #12395)
-rw-r--r-- | src/move.c | 6 | ||||
-rw-r--r-- | src/testdir/dumps/Test_display_cursor_long_line.dump | 8 | ||||
-rw-r--r-- | src/testdir/dumps/Test_display_cursor_long_line_1.dump | 8 | ||||
-rw-r--r-- | src/testdir/dumps/Test_display_cursor_long_line_2.dump | 8 | ||||
-rw-r--r-- | src/testdir/dumps/Test_display_cursor_long_line_3.dump | 8 | ||||
-rw-r--r-- | src/testdir/dumps/Test_display_cursor_long_line_4.dump | 8 | ||||
-rw-r--r-- | src/testdir/test_display.vim | 19 | ||||
-rw-r--r-- | src/testdir/test_scroll_opt.vim | 2 | ||||
-rw-r--r-- | src/textobject.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
10 files changed, 58 insertions, 13 deletions
diff --git a/src/move.c b/src/move.c index d969de2fc..93c101b79 100644 --- a/src/move.c +++ b/src/move.c @@ -1960,12 +1960,14 @@ adjust_skipcol(void) curwin->w_skipcol -= width2; else curwin->w_skipcol -= width1; - redraw_later(UPD_NOT_VALID); scrolled = TRUE; - validate_virtcol(); } if (scrolled) + { + validate_virtcol(); + redraw_later(UPD_NOT_VALID); return; // don't scroll in the other direction now + } int col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols; int row = 0; diff --git a/src/testdir/dumps/Test_display_cursor_long_line.dump b/src/testdir/dumps/Test_display_cursor_long_line.dump deleted file mode 100644 index eafad8c9d..000000000 --- a/src/testdir/dumps/Test_display_cursor_long_line.dump +++ /dev/null @@ -1,8 +0,0 @@ -|<+0#4040ff13#ffffff0@2|b+0#0000000&@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| -|b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@2 -@2| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| -|b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@2 -@2| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| -|b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@2 -@2| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4| |b@4> -@57|2|,|6|0@1| @8|5|0|%| diff --git a/src/testdir/dumps/Test_display_cursor_long_line_1.dump b/src/testdir/dumps/Test_display_cursor_long_line_1.dump new file mode 100644 index 000000000..a54a17f5e --- /dev/null +++ b/src/testdir/dumps/Test_display_cursor_long_line_1.dump @@ -0,0 +1,8 @@ +|<+0#4040ff13#ffffff0@2|b+0#0000000&@71 +@75 +@75 +@75 +@75 +@75 +@1>b| @72 +@57|2|,|7|5|2| @8|5|0|%| diff --git a/src/testdir/dumps/Test_display_cursor_long_line_2.dump b/src/testdir/dumps/Test_display_cursor_long_line_2.dump new file mode 100644 index 000000000..cdae4bac4 --- /dev/null +++ b/src/testdir/dumps/Test_display_cursor_long_line_2.dump @@ -0,0 +1,8 @@ +|<+0#4040ff13#ffffff0@2|b+0#0000000&>b@70 +@75 +@75 +@75 +@75 +@75 +@75 +| @56|2|,|1| @10|5|0|%| diff --git a/src/testdir/dumps/Test_display_cursor_long_line_3.dump b/src/testdir/dumps/Test_display_cursor_long_line_3.dump new file mode 100644 index 000000000..a736d9d16 --- /dev/null +++ b/src/testdir/dumps/Test_display_cursor_long_line_3.dump @@ -0,0 +1,8 @@ +| +0#af5f00255#ffffff0@1|2| |b+0#0000000&| >b@68 +@75 +@75 +@75 +@75 +@75 +@75 +| @56|2|,|3| @10|5|0|%| diff --git a/src/testdir/dumps/Test_display_cursor_long_line_4.dump b/src/testdir/dumps/Test_display_cursor_long_line_4.dump new file mode 100644 index 000000000..0f54c4344 --- /dev/null +++ b/src/testdir/dumps/Test_display_cursor_long_line_4.dump @@ -0,0 +1,8 @@ +| +0#af5f00255#ffffff0@1|2| >b+0#0000000&| |b@68 +@75 +@75 +@75 +@75 +@75 +@75 +| @56|2|,|1| @10|5|0|%| diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim index 1332ab55e..f817a8502 100644 --- a/src/testdir/test_display.vim +++ b/src/testdir/test_display.vim @@ -507,14 +507,29 @@ func Test_display_cursor_long_line() CheckScreendump let lines =<< trim END - call setline(1, ['a', 'bbbbb '->repeat(100), 'c']) + call setline(1, ['a', 'b ' .. 'bbbbb'->repeat(150), 'c']) norm $j END call writefile(lines, 'XdispCursorLongline', 'D') let buf = RunVimInTerminal('-S XdispCursorLongline', #{rows: 8}) - call VerifyScreenDump(buf, 'Test_display_cursor_long_line', {}) + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_1', {}) + + " FIXME: moving the cursor above the topline does not set w_skipcol + " correctly with cpo+=n and zero scrolloff (curs_columns() extra == 1). + call term_sendkeys(buf, ":set number cpo+=n scrolloff=0\<CR>") + call term_sendkeys(buf, '$0') + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_2', {}) + + " Going to the start of the line with "b" did not set w_skipcol correctly + " with 'smoothscroll'. + call term_sendkeys(buf, ":set smoothscroll\<CR>") + call term_sendkeys(buf, '$b') + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_3', {}) + " Same for "ge". + call term_sendkeys(buf, '$ge') + call VerifyScreenDump(buf, 'Test_display_cursor_long_line_4', {}) call StopVimInTerminal(buf) endfunc diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim index 636e7b76c..469cf1271 100644 --- a/src/testdir/test_scroll_opt.vim +++ b/src/testdir/test_scroll_opt.vim @@ -502,7 +502,7 @@ func Test_smoothscroll_cursor_position() " regardless of number and cpo-=n. setl number list listchars=precedes:< cpo-=n call s:check_col_calc(5, 1, 1) - exe "normal 2|\<C-E>" + exe "normal 3|\<C-E>h" call s:check_col_calc(6, 1, 18) norm h call s:check_col_calc(5, 2, 17) diff --git a/src/textobject.c b/src/textobject.c index d77ec961a..b315d0320 100644 --- a/src/textobject.c +++ b/src/textobject.c @@ -472,6 +472,7 @@ bck_word(long count, int bigword, int stop) finished: stop = FALSE; } + adjust_skipcol(); return OK; } @@ -598,6 +599,7 @@ bckend_word( return OK; } } + adjust_skipcol(); return OK; } diff --git a/src/version.c b/src/version.c index 7d691e372..9f6484354 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1561, +/**/ 1560, /**/ 1559, |