bwipe!
endfunc
+func Test_smoothscroll_keep_skipcol()
+ call NewWindow(10, 40)
+ setlocal smoothscroll
+ call setline(1, ['abcde '->repeat(150)]->repeat(2))
+
+ exe "norm! 10\<C-E>"
+ redraw
+ let skipcol = winsaveview().skipcol
+ call assert_notequal(0, skipcol)
+
+ " Changing the height of the window must not reset the scroll position.
+ resize -3
+ resize +3
+ redraw
+ call assert_equal(skipcol, winsaveview().skipcol)
+
+ " Using the autocommand window changes the height as well.
+ call bufload(bufadd(''))
+ redraw
+ call assert_equal(skipcol, winsaveview().skipcol)
+
+ bwipe!
+endfunc
+
func Test_smoothscroll_long_line_zb()
call NewWindow(10, 40)
call setline(1, 'abcde '->repeat(150))
// values might be invalid.
if (!exiting && *p_spk == 'c')
{
- wp->w_skipcol = 0;
+ // With 'smoothscroll' w_skipcol is the scroll position, keep it.
+ // Otherwise it only keeps the cursor visible and is computed again.
+ if (!wp->w_p_sms)
+ wp->w_skipcol = 0;
scroll_to_fraction(wp, prev_height);
}
}
if (wp->w_wrow >= wp->w_height
&& (wp->w_width - win_col_off(wp)) > 0)
{
- wp->w_skipcol += wp->w_width - win_col_off(wp);
+ // The cursor must be visible, override the scroll position.
+ colnr_T skipcol = wp->w_width - win_col_off(wp);
+
--wp->w_wrow;
while (wp->w_wrow >= wp->w_height)
{
- wp->w_skipcol += wp->w_width - win_col_off(wp)
- + win_col_off2(wp);
+ skipcol += wp->w_width - win_col_off(wp) + win_col_off2(wp);
--wp->w_wrow;
}
+ wp->w_skipcol = skipcol;
}
}
else if (sline > 0)