patch 9.1.1964: Wrong display when using setline() at hit-enter prompt

Problem:  Wrong display when using setline() at hit-enter prompt
          (after 8.2.3204).
Solution: Only skip scrolling for changed lines in top area if it's
          scrolled down due to w_topline change. Also add more testing
          for what 8.2.3204 fixed (zeertzjq).

closes: #18887

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2025-12-09 13:10:12 +01:00
committed by Christian Brabandt
parent 4af6d9755c
commit e72eacceab
7 changed files with 75 additions and 7 deletions

View File

@ -2282,11 +2282,11 @@ win_update(win_T *wp)
// When at start of changed lines: May scroll following lines
// up or down to minimize redrawing.
// Don't do this when the change continues until the end.
// Don't scroll the top area which was already scrolled above,
// but do scroll for changed lines below the top area.
// Don't scroll for changed lines in the top area if that's already
// done above, but do scroll for changed lines below the top area.
if (!scrolled_for_mod && mod_bot != MAXLNUM
&& lnum >= mod_top && lnum < MAX(mod_bot, mod_top + 1)
&& row >= top_end)
&& (!scrolled_down || row >= top_end))
{
scrolled_for_mod = TRUE;

View File

@ -0,0 +1,8 @@
>1+0&#ffffff0| @38
|2| @38
|3| @38
|4| @38
|5| @38
|6| @38
|7| @38
@22|1|,|1| @10|T|o|p|

View File

@ -0,0 +1,8 @@
|4+0&#ffffff0| @38
|5| @38
|6| @38
|7| @38
|a|b|c| @36
|d|e|f| @36
|g|h|i| @36
|P+0#00e0003&|r|e|s@1| |E|N|T|E|R| |o|r| |t|y|p|e| |c|o|m@1|a|n|d| |t|o| |c|o|n|t|i|n|u|e> +0#0000000&

View File

@ -0,0 +1,8 @@
>1+0&#ffffff0| @38
|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f
|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o
@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1| @14
|3| @38
|4| @38
|5| @38
@22|1|,|1| @10|T|o|p|

View File

@ -0,0 +1,15 @@
| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r|b|a|r|b|a|r|b|a|r|b|a|r|b|a|r
| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r|b|a|r|b|a|r|b|a|r| @5
|>| |7|3| @15
| +0#0000e05#a8a8a8255@1|7+0#0000000#ffffff0|4| @15
|>| |7|5| @15
| +0#0000e05#a8a8a8255@1|7+0#0000000#ffffff0|6| @15
| +0#0000e05#a8a8a8255@1>7+0#0000000#ffffff0@1| @15
| +0#0000e05#a8a8a8255@1|7+0#0000000#ffffff0|8| @15
| +0#0000e05#a8a8a8255@1|7+0#0000000#ffffff0|9| @15
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1|f|o@1|f|o@1|f|o@1|f|o@1|f|o@1
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1|f|o@1|f|o@1| @8
| +0#0000e05#a8a8a8255@1|8+0#0000000#ffffff0|1| @15
| +0#0000e05#a8a8a8255@1|8+0#0000000#ffffff0|2| @15
@10|7@1|,|1| @1|7|9|%|

View File

@ -272,13 +272,19 @@ func Test_display_scroll_setline()
setlocal scrolloff=5 signcolumn=yes
call setline(1, range(1, 100))
call sign_define('foo', #{text: '>'})
call sign_place(1, 'bar', 'foo', bufnr(), #{lnum: 73})
call sign_place(2, 'bar', 'foo', bufnr(), #{lnum: 74})
call sign_place(3, 'bar', 'foo', bufnr(), #{lnum: 75})
call sign_place(1, 'bar', 'foo', bufnr(), #{lnum: 71})
call sign_place(2, 'bar', 'foo', bufnr(), #{lnum: 72})
call sign_place(3, 'bar', 'foo', bufnr(), #{lnum: 73})
call sign_place(4, 'bar', 'foo', bufnr(), #{lnum: 74})
call sign_place(5, 'bar', 'foo', bufnr(), #{lnum: 75})
normal! G
autocmd CursorMoved * if line('.') == 79
\ | call sign_unplace('bar', #{id: 2})
\ | call sign_unplace('bar', #{id: 4})
\ | call setline(80, repeat('foo', 15))
\ | elseif line('.') == 78
\ | call setline(72, repeat('bar', 10))
\ | elseif line('.') == 77
\ | call sign_unplace('bar', #{id: 2})
\ | endif
END
call writefile(lines, 'XscrollSetline.vim', 'D')
@ -293,6 +299,27 @@ func Test_display_scroll_setline()
call VerifyScreenDump(buf, 'Test_display_scroll_setline_4', {})
call term_sendkeys(buf, 'k')
call VerifyScreenDump(buf, 'Test_display_scroll_setline_5', {})
call term_sendkeys(buf, 'k')
call VerifyScreenDump(buf, 'Test_display_scroll_setline_6', {})
call StopVimInTerminal(buf)
endfunc
func Test_display_hit_enter_setline()
CheckScreendump
let lines =<< trim END
call setline(1, range(1, 100))
END
call writefile(lines, 'XhitEnterSetline.vim', 'D')
let buf = RunVimInTerminal('-S XhitEnterSetline.vim', #{rows: 8, cols: 40})
call VerifyScreenDump(buf, 'Test_display_hit_enter_setline_1', {})
call term_sendkeys(buf, ':echo "abc\ndef\nghi"')
call term_sendkeys(buf, "\<CR>")
call VerifyScreenDump(buf, 'Test_display_hit_enter_setline_2', {})
call term_sendkeys(buf, ":call setline(2, repeat('foo', 35))\<CR>")
call VerifyScreenDump(buf, 'Test_display_hit_enter_setline_3', {})
call StopVimInTerminal(buf)
endfunc

View File

@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1964,
/**/
1963,
/**/