patch 9.1.1482: scrolling with 'splitkeep' and line() Commit: https://github.com/vim/vim/commit/fe803c8c04c1b73453c0dab970863ab53e3eeec7 Author: Luuk van Baal <luukvb...@gmail.com> Date: Thu Jun 26 20:34:15 2025 +0200
patch 9.1.1482: scrolling with 'splitkeep' and line() 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 <luukvb...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/evalfunc.c b/src/evalfunc.c index 76955a7ed..2e864f74f 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -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 index 000000000..7a387baec --- /dev/null +++ b/src/testdir/dumps/Test_splitkeep_line_1.dump @@ -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 index 000000000..c322f1d31 --- /dev/null +++ b/src/testdir/dumps/Test_splitkeep_line_2.dump @@ -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 diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim index c5edb0d4a..4e02f0098 100644 --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -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>" diff --git a/src/version.c b/src/version.c index c7c66ec0b..67346ec22 100644 --- a/src/version.c +++ b/src/version.c @@ -709,6 +709,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1482, /**/ 1481, /**/ -- -- 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 vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1uUraw-004vWz-8H%40256bit.org.