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

Commit: 
https://github.com/vim/vim/commit/e72eacceab2647e37e7d7a8a70e89dcd6ad01288
Author: zeertzjq <[email protected]>
Date:   Tue Dec 9 13:10:12 2025 +0100

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/drawscreen.c b/src/drawscreen.c
index c6baf0ca8..5c7ecfed9 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -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;
 
diff --git a/src/testdir/dumps/Test_display_hit_enter_setline_1.dump 
b/src/testdir/dumps/Test_display_hit_enter_setline_1.dump
new file mode 100644
index 000000000..e51dd0ec2
--- /dev/null
+++ b/src/testdir/dumps/Test_display_hit_enter_setline_1.dump
@@ -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| 
diff --git a/src/testdir/dumps/Test_display_hit_enter_setline_2.dump 
b/src/testdir/dumps/Test_display_hit_enter_setline_2.dump
new file mode 100644
index 000000000..982659481
--- /dev/null
+++ b/src/testdir/dumps/Test_display_hit_enter_setline_2.dump
@@ -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&
diff --git a/src/testdir/dumps/Test_display_hit_enter_setline_3.dump 
b/src/testdir/dumps/Test_display_hit_enter_setline_3.dump
new file mode 100644
index 000000000..15ea35788
--- /dev/null
+++ b/src/testdir/dumps/Test_display_hit_enter_setline_3.dump
@@ -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| 
diff --git a/src/testdir/dumps/Test_display_scroll_setline_6.dump 
b/src/testdir/dumps/Test_display_scroll_setline_6.dump
new file mode 100644
index 000000000..65e0187dc
--- /dev/null
+++ b/src/testdir/dumps/Test_display_scroll_setline_6.dump
@@ -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|%| 
diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim
index 3eca1765c..7717b866b 100644
--- a/src/testdir/test_display.vim
+++ b/src/testdir/test_display.vim
@@ -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
def
ghi"')
+  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
diff --git a/src/version.c b/src/version.c
index 6e48a748d..fef7febbb 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1964,
 /**/
     1963,
 /**/

-- 
-- 
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 visit 
https://groups.google.com/d/msgid/vim_dev/E1vSwcU-006Q42-8a%40256bit.org.

Raspunde prin e-mail lui