Patch 9.0.1543
Problem: Display errors when making topline shorter and 'smoothscroll' is
set.
Solution: Reset w_skipcol when the topline becomes shorter than its current
value. (Luuk van Baal, closes #12367)
Files: src/change.c, src/testdir/test_display.vim,
src/testdir/test_scroll_opt.vim,
src/testdir/dumps/Test_display_long_line_1.dump,
src/testdir/dumps/Test_display_long_line_2.dump,
src/testdir/dumps/Test_display_long_line_3.dump,
src/testdir/dumps/Test_display_long_line_4.dump,
src/testdir/dumps/Test_smooth_long_15.dump,
src/testdir/dumps/Test_smooth_long_16.dump
*** ../vim-9.0.1542/src/change.c 2023-02-04 13:57:27.608749797 +0000
--- src/change.c 2023-05-11 19:22:03.256939036 +0100
***************
*** 553,565 ****
{
if (wp->w_buffer == curbuf)
{
- #ifdef FEAT_FOLDING
linenr_T last = lnume + xtra - 1; // last line after the change
! #endif
// Mark this window to be redrawn later.
if (!redraw_not_allowed && wp->w_redr_type < UPD_VALID)
wp->w_redr_type = UPD_VALID;
// Check if a change in the buffer has invalidated the cached
// values for the cursor.
#ifdef FEAT_FOLDING
--- 553,577 ----
{
if (wp->w_buffer == curbuf)
{
linenr_T last = lnume + xtra - 1; // last line after the change
!
// Mark this window to be redrawn later.
if (!redraw_not_allowed && wp->w_redr_type < UPD_VALID)
wp->w_redr_type = UPD_VALID;
+ // Reset "w_skipcol" if the topline length has become smaller to
+ // such a degree that nothing will be visible anymore, accounting
+ // for 'smoothscroll' <<< or 'listchars' "precedes" marker.
+ if (wp->w_skipcol > 0
+ && (last < wp->w_topline
+ || (wp->w_topline >= lnum
+ && wp->w_topline < lnume
+ && win_linetabsize(wp, wp->w_topline,
+ ml_get(wp->w_topline), (colnr_T)MAXCOL)
+ <= wp->w_skipcol + (wp->w_p_list
+ && wp->w_lcs_chars.prec ? 1 : 3))))
+ wp->w_skipcol = 0;
+
// Check if a change in the buffer has invalidated the cached
// values for the cursor.
#ifdef FEAT_FOLDING
*** ../vim-9.0.1542/src/testdir/test_display.vim 2023-05-11
18:37:57.441591098 +0100
--- src/testdir/test_display.vim 2023-05-11 19:15:24.385147906 +0100
***************
*** 471,479 ****
CheckScreendump
let lines =<< trim END
! set display=lastline
call setline(1, [
! \'aaaaa'->repeat(100),
\'bbbbb '->repeat(7) .. 'ccccc '->repeat(7) .. 'ddddd '->repeat(7)
\])
END
--- 471,479 ----
CheckScreendump
let lines =<< trim END
! set display=lastline smoothscroll scrolloff=0
call setline(1, [
! \'aaaaa'->repeat(150),
\'bbbbb '->repeat(7) .. 'ccccc '->repeat(7) .. 'ddddd '->repeat(7)
\])
END
***************
*** 481,491 ****
call writefile(lines, 'XdispLongline', 'D')
let buf = RunVimInTerminal('-S XdispLongline', #{rows: 14, cols: 35})
! call term_sendkeys(buf, "482|")
call VerifyScreenDump(buf, 'Test_display_long_line_1', {})
call term_sendkeys(buf, "D")
call VerifyScreenDump(buf, 'Test_display_long_line_2', {})
call StopVimInTerminal(buf)
endfunc
--- 481,503 ----
call writefile(lines, 'XdispLongline', 'D')
let buf = RunVimInTerminal('-S XdispLongline', #{rows: 14, cols: 35})
! call term_sendkeys(buf, "736|")
call VerifyScreenDump(buf, 'Test_display_long_line_1', {})
+
+ " The correct part of the last line is moved into view.
call term_sendkeys(buf, "D")
call VerifyScreenDump(buf, 'Test_display_long_line_2', {})
+ " "w_skipcol" does not change because the topline is still long enough
+ " to maintain the current skipcol.
+ call term_sendkeys(buf, "g04l11gkD")
+ call VerifyScreenDump(buf, 'Test_display_long_line_3', {})
+
+ " "w_skipcol" is reset to bring the entire topline into view because
+ " the line length is now smaller than the current skipcol + marker.
+ call term_sendkeys(buf, "x")
+ call VerifyScreenDump(buf, 'Test_display_long_line_4', {})
+
call StopVimInTerminal(buf)
endfunc
*** ../vim-9.0.1542/src/testdir/test_scroll_opt.vim 2023-05-09
21:23:48.762914107 +0100
--- src/testdir/test_scroll_opt.vim 2023-05-11 19:15:24.385147906 +0100
***************
*** 335,343 ****
" than one window. Note that the cursor is at the bottom this time because
" Vim prefers to do so if we are scrolling a few lines only.
call term_sendkeys(buf, ":call setline(1, ['one', 'two', 'Line' .. (' with
lots of text'->repeat(10)) .. ' end', 'four'])\<CR>")
call term_sendkeys(buf, "3Gzt")
call term_sendkeys(buf, "j")
! call VerifyScreenDump(buf, 'Test_smooth_long_14', {})
" Repeat the step but this time start it when the line is smooth-scrolled by
" one line. This tests that the offset calculation is still correct and
--- 335,346 ----
" than one window. Note that the cursor is at the bottom this time because
" Vim prefers to do so if we are scrolling a few lines only.
call term_sendkeys(buf, ":call setline(1, ['one', 'two', 'Line' .. (' with
lots of text'->repeat(10)) .. ' end', 'four'])\<CR>")
+ " Currently visible lines were replaced, test that the lines and cursor
+ " are correctly displayed.
+ call VerifyScreenDump(buf, 'Test_smooth_long_14', {})
call term_sendkeys(buf, "3Gzt")
call term_sendkeys(buf, "j")
! call VerifyScreenDump(buf, 'Test_smooth_long_15', {})
" Repeat the step but this time start it when the line is smooth-scrolled by
" one line. This tests that the offset calculation is still correct and
***************
*** 345,351 ****
" screen.
call term_sendkeys(buf, "3Gzt")
call term_sendkeys(buf, "\<C-E>j")
! call VerifyScreenDump(buf, 'Test_smooth_long_15', {})
call StopVimInTerminal(buf)
endfunc
--- 348,354 ----
" screen.
call term_sendkeys(buf, "3Gzt")
call term_sendkeys(buf, "\<C-E>j")
! call VerifyScreenDump(buf, 'Test_smooth_long_16', {})
call StopVimInTerminal(buf)
endfunc
*** ../vim-9.0.1542/src/testdir/dumps/Test_display_long_line_1.dump
2023-04-30 19:15:09.285424145 +0100
--- src/testdir/dumps/Test_display_long_line_1.dump 2023-05-11
19:15:24.385147906 +0100
***************
*** 9,14 ****
@35
@35
@35
! @26>a@8
! @10| @24
! @18|1|,|4|8|2| @7|T|o|p|
--- 9,14 ----
@35
@35
@35
! @35
! >a@14| @19
! @18|1|,|7|3|6| @7|T|o|p|
*** ../vim-9.0.1542/src/testdir/dumps/Test_display_long_line_2.dump
2023-04-30 19:15:09.285424145 +0100
--- src/testdir/dumps/Test_display_long_line_2.dump 2023-05-11
19:15:24.385147906 +0100
***************
*** 9,14 ****
@35
@35
@35
! @25>a| @8
|b@4| |b@4| |b@4| |b@4| |b@4| |b@1|@+0#4040ff13&@2
! | +0#0000000&@17|1|,|4|8|1| @7|T|o|p|
--- 9,14 ----
@35
@35
@35
! @34>a
|b@4| |b@4| |b@4| |b@4| |b@4| |b@1|@+0#4040ff13&@2
! | +0#0000000&@17|1|,|7|3|5| @7|T|o|p|
*** ../vim-9.0.1542/src/testdir/dumps/Test_display_long_line_3.dump
2023-05-11 19:23:01.016907708 +0100
--- src/testdir/dumps/Test_display_long_line_3.dump 2023-05-11
19:15:24.385147906 +0100
***************
*** 0 ****
--- 1,14 ----
+ |<+0#4040ff13#ffffff0@2>a+0#0000000&| @30
+ |b@4| |b@4| |b@4| |b@4| |b@4| |b@4
+ | |b@4| |c@4| |c@4| |c@4| |c@4| |c@3
+ @1| |c@4| |c@4| |d@4| |d@4| |d@4| |d@2
+ @2| |d@4| |d@4| |d@4| @14
+ |~+0#4040ff13&| @33
+ |~| @33
+ |~| @33
+ |~| @33
+ |~| @33
+ |~| @33
+ |~| @33
+ |~| @33
+ | +0#0000000&@17|1|,|3|1|9| @7|A|l@1|
*** ../vim-9.0.1542/src/testdir/dumps/Test_display_long_line_4.dump
2023-05-11 19:23:01.024907702 +0100
--- src/testdir/dumps/Test_display_long_line_4.dump 2023-05-11
19:15:24.385147906 +0100
***************
*** 0 ****
--- 1,14 ----
+ |a+0&#ffffff0@34
+ @35
+ @35
+ @35
+ @35
+ @35
+ @35
+ @35
+ @35
+ @2>a| @31
+ |b@4| |b@4| |b@4| |b@4| |b@4| |b@4
+ | |b@4| |c@4| |c@4| |c@4| |c@4| |c@3
+ @1| |c@4| |c@4| |d@4| |d@4| |d@4| |@+0#4040ff13&@2
+ | +0#0000000&@17|1|,|3|1|8| @7|T|o|p|
*** ../vim-9.0.1542/src/testdir/dumps/Test_smooth_long_15.dump 2022-12-31
15:12:58.050637307 +0000
--- src/testdir/dumps/Test_smooth_long_15.dump 2023-05-11 19:15:24.385147906
+0100
***************
*** 2,6 ****
|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h|
|l|o
|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s|
|o
|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |e|n|d| @11
! |f|o|u>r| @35
! @22|4|,|4| @10|B|o|t|
--- 2,6 ----
|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h|
|l|o
|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s|
|o
|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |e|n|d| @11
! >f|o|u|r| @35
! @22|4|,|1| @10|B|o|t|
*** ../vim-9.0.1542/src/testdir/dumps/Test_smooth_long_16.dump 2023-05-11
19:23:01.032907699 +0100
--- src/testdir/dumps/Test_smooth_long_16.dump 2023-05-11 19:15:24.385147906
+0100
***************
*** 0 ****
--- 1,6 ----
+ |<+0#4040ff13#ffffff0@2|t+0#0000000&|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h|
|l|o|t|s| |o|f| |t|e|x|t| |w|i|t
+ |h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h|
|l|o
+ |t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s|
|o
+ |f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |e|n|d| @11
+ |f|o|u>r| @35
+ @22|4|,|4| @10|B|o|t|
*** ../vim-9.0.1542/src/version.c 2023-05-11 18:37:57.441591098 +0100
--- src/version.c 2023-05-11 19:20:06.781001521 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1543,
/**/
--
How To Keep A Healthy Level Of Insanity:
18. When leaving the zoo, start running towards the parking lot,
yelling "run for your lives, they're loose!!"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230511182459.09DD51C0916%40moolenaar.net.