Skip to content

Commit

Permalink
'splitkeep' uses old botline when buffer line count changed
Browse files Browse the repository at this point in the history
Problem:	'splitkeep' uses old botline when buffer line count changed.
Solution:	Check that buffer line count is larger than botline (Fixes #11292).
  • Loading branch information
luukvbaal committed Oct 5, 2022
1 parent 0816f47 commit ae580ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/testdir/test_window_cmd.vim
Expand Up @@ -1807,6 +1807,13 @@ function Test_splitkeep_misc()
let top = line('w0')
help | quit
call assert_equal(top, line('w0'))
" No error when resizing window in autocmd and buffer length changed
autocmd FileType qf exe "resize" line('$')
cexpr getline(1, '$')
copen
wincmd p
norm dd
cexpr getline(1, '$')

%bwipeout!
set splitbelow&
Expand Down
3 changes: 2 additions & 1 deletion src/window.c
Expand Up @@ -6356,7 +6356,8 @@ win_fix_scroll(int resize)
if (wp->w_height != wp->w_prev_height)
{
// If window has moved update botline to keep the same screenlines.
if (*p_spk == 's' && wp->w_winrow != wp->w_prev_winrow)
if (*p_spk == 's' && wp->w_winrow != wp->w_prev_winrow
&& wp->w_buffer->b_ml.ml_line_count >= wp->w_botline - 1)
{
lnum = wp->w_cursor.lnum;
diff = (wp->w_winrow - wp->w_prev_winrow)
Expand Down

0 comments on commit ae580ad

Please sign in to comment.