]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1482: scrolling with 'splitkeep' and line() v9.1.1482
authorLuuk van Baal <luukvbaal@gmail.com>
Thu, 26 Jun 2025 18:34:15 +0000 (20:34 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 26 Jun 2025 18:34:15 +0000 (20:34 +0200)
Problem:  Topline is preemptively updated by line() in WinResized
          autocmd with 'splitkeep' != "cursor".
Solution: Set `skip_update_topline` when 'splitkeep' != "cursor".
          (Luuk van Baal)

related: neovim/neovim#34666
closes: #17613

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/evalfunc.c
src/testdir/dumps/Test_splitkeep_line_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_splitkeep_line_2.dump [new file with mode: 0644]
src/testdir/test_window_cmd.vim
src/version.c

index 76955a7ed0fafcf714db610ba6862cef653791f1..2e864f74fcf5dc1515fec6adc35e74f9a43eb4cc 100644 (file)
@@ -8833,19 +8833,18 @@ f_line(typval_T *argvars, typval_T *rettv)
        {
            if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
            {
+               // With 'splitkeep' != cursor and in diff mode, prevent that the
+               // window scrolls and keep the topline.
+               if (*p_spk != 'c'
 #ifdef FEAT_DIFF
-               // in diff mode, prevent that the window scrolls
-               // and keep the topline
-               if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff)
-                   skip_update_topline = TRUE;
+               || (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff)
 #endif
+               )
+                   skip_update_topline = TRUE;
                check_cursor();
                fp = var2fpos(&argvars[0], TRUE, &fnum, FALSE);
            }
-#ifdef FEAT_DIFF
-           if (curwin->w_p_diff && switchwin.sw_curwin->w_p_diff)
-               skip_update_topline = FALSE;
-#endif
+           skip_update_topline = FALSE;
            restore_win_noblock(&switchwin, TRUE);
        }
     }
diff --git a/src/testdir/dumps/Test_splitkeep_line_1.dump b/src/testdir/dumps/Test_splitkeep_line_1.dump
new file mode 100644 (file)
index 0000000..7a387ba
--- /dev/null
@@ -0,0 +1,6 @@
+>0+0&#ffffff0| @38
+|1| @38
+|2| @38
+|3| @38
+|4| @38
+@22|1|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_splitkeep_line_2.dump b/src/testdir/dumps/Test_splitkeep_line_2.dump
new file mode 100644 (file)
index 0000000..c322f1d
--- /dev/null
@@ -0,0 +1,6 @@
+>0+0&#ffffff0| @38
+|1| @38
+|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @8|1|,|1| @11|T|o|p
+|3+0&&| @38
+|[+1&&|N|o| |N|a|m|e|]| |[|+|]| @8|1|,|1| @12|0|%
+|:+0&&|w|i|n|c|m|d| |s| @30
index c5edb0d4a871c7cad6e5cc8cba8736d7a6af66a5..4e02f0098340f17527bf9750b934e40f651cc900 100644 (file)
@@ -2120,6 +2120,24 @@ func Test_splitkeep_skipcol()
   call VerifyScreenDump(buf, 'Test_splitkeep_skipcol_1', {})
 endfunc
 
+func Test_splitkeep_line()
+  CheckScreendump
+
+  let lines =<< trim END
+    set splitkeep=screen nosplitbelow
+    autocmd WinResized * call line('w0', 1000)
+    call setline(1, range(1000))
+  END
+
+  call writefile(lines, 'XTestSplitkeepSkipcol', 'D')
+  let buf = RunVimInTerminal('-S XTestSplitkeepSkipcol', #{rows: 6, cols: 40})
+
+  call VerifyScreenDump(buf, 'Test_splitkeep_line_1', {})
+
+  call term_sendkeys(buf, ":wincmd s\<CR>")
+  call VerifyScreenDump(buf, 'Test_splitkeep_line_2', {})
+endfunc
+
 func Test_new_help_window_on_error()
   help change.txt
   execute "normal! /CTRL-@\<CR>"
index c7c66ec0bce6bcd2534eaae6d85279f57efdfd64..67346ec22eb549bc95c480a3adb8a37d620dda6d 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1482,
 /**/
     1481,
 /**/