Skip to content

Commit

Permalink
restore_snapshot causes scrolling for 'nosplitscroll'
Browse files Browse the repository at this point in the history
Problem:    Lines are scrolled when snapshot is restored.
Solution:   Call win_fix_scroll() in restore_snapshot() (closes #11115).
  • Loading branch information
luukvbaal committed Sep 12, 2022
1 parent 8acd0d5 commit 8e1cde6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/testdir/test_window_cmd.vim
Expand Up @@ -1646,7 +1646,7 @@ func Test_splitscroll_with_splits()
for so in [0, 5]
for ls in range(0, 2)
for pos in ["H", "M", "L"]
tabnew | tabonly!
tabnew | tabonly! | redraw
let tabline = (gui ? 0 : (tab ? 1 : 0))
let winbar_sb = (sb ? winbar : 0)
execute 'set scrolloff=' . so
Expand All @@ -1656,9 +1656,17 @@ func Test_splitscroll_with_splits()
execute tab ? 'tabnew' : ''
execute winbar ? 'nnoremenu 1.10 WinBar.Test :echo' : ''
call setline(1, range(1, 256))
execute 'norm gg' . pos | redraw!
" No scroll for restore_snapshot
norm G
try
copen | close | colder
catch /E380/
endtry
call assert_equal(257 - winheight(0), line("w0"))

" No scroll for firstwin horizontal split
split | redraw! | wincmd k
execute 'norm gg' . pos
split | redraw | wincmd k
call assert_equal(1, line("w0"))
wincmd j
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
Expand Down Expand Up @@ -1714,7 +1722,7 @@ func Test_splitscroll_with_splits()
call assert_equal(1, line("w0"))

" No scroll in windows split and quit multiple times
quit | redraw! | split | split | quit
quit | redraw | split | redraw | split | redraw | quit | redraw
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))

" No scroll for new buffer
Expand Down
2 changes: 2 additions & 0 deletions src/window.c
Expand Up @@ -7094,6 +7094,8 @@ restore_snapshot(
win_comp_pos();
if (wp != NULL && close_curwin)
win_goto(wp);
if (!p_spsc)
win_fix_scroll(FALSE);
redraw_all_later(UPD_NOT_VALID);
}
clear_snapshot(curtab, idx);
Expand Down

0 comments on commit 8e1cde6

Please sign in to comment.