]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1964: Wrong display when using setline() at hit-enter prompt v9.1.1964
authorzeertzjq <zeertzjq@outlook.com>
Tue, 9 Dec 2025 12:10:12 +0000 (13:10 +0100)
committerChristian Brabandt <cb@256bit.org>
Tue, 9 Dec 2025 12:10:12 +0000 (13:10 +0100)
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>
src/drawscreen.c
src/testdir/dumps/Test_display_hit_enter_setline_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_display_hit_enter_setline_2.dump [new file with mode: 0644]
src/testdir/dumps/Test_display_hit_enter_setline_3.dump [new file with mode: 0644]
src/testdir/dumps/Test_display_scroll_setline_6.dump [new file with mode: 0644]
src/testdir/test_display.vim
src/version.c

index c6baf0ca83a78e39a91c15d4f3aed0a38c654c88..5c7ecfed9a632e108634dcf8ea861db5dfca9f56 100644 (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;
 
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 (file)
index 0000000..e51dd0e
--- /dev/null
@@ -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 (file)
index 0000000..9826594
--- /dev/null
@@ -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 (file)
index 0000000..15ea357
--- /dev/null
@@ -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 (file)
index 0000000..65e0187
--- /dev/null
@@ -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|%| 
index 3eca1765ca32cd670dbfcad866083254759010ea..7717b866ba0ba03e71f3ce2827d6a83ea40a75b3 100644 (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
index 6e48a748dba32be04253f187bd40c92b2dc94867..fef7febbb9fcd234c12f08ddee7acd077daf5297 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1964,
 /**/
     1963,
 /**/