mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 01:51:52 +00:00
vim-patch:9.2.0881: 'smoothscroll' position is lost when the window height changes
Problem: With 'smoothscroll' the scroll position of a window is lost when
its height changes.
Solution: Only reset the skipped columns when 'smoothscroll' is off, where
they just serve to keep the cursor visible.
closes: vim/vim#20885
17f3923b8c
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6946,13 +6946,14 @@ void scroll_to_fraction(win_T *wp, int prev_height)
|
||||
wp->w_wrow = line_size;
|
||||
if (wp->w_wrow >= wp->w_view_height
|
||||
&& (wp->w_view_width - win_col_off(wp)) > 0) {
|
||||
wp->w_skipcol += wp->w_view_width - win_col_off(wp);
|
||||
// The cursor must be visible, override the scroll position.
|
||||
colnr_T skipcol = wp->w_view_width - win_col_off(wp);
|
||||
wp->w_wrow--;
|
||||
while (wp->w_wrow >= wp->w_view_height) {
|
||||
wp->w_skipcol += wp->w_view_width - win_col_off(wp)
|
||||
+ win_col_off2(wp);
|
||||
skipcol += wp->w_view_width - win_col_off(wp) + win_col_off2(wp);
|
||||
wp->w_wrow--;
|
||||
}
|
||||
wp->w_skipcol = skipcol;
|
||||
}
|
||||
} else if (sline > 0) {
|
||||
while (sline > 0 && lnum > 1) {
|
||||
@@ -7032,7 +7033,11 @@ void win_set_inner_size(win_T *wp, bool valid_cursor)
|
||||
// There is no point in adjusting the scroll position when exiting. Some
|
||||
// values might be invalid.
|
||||
if (valid_cursor && !exiting && (*p_spk == 'c' || wp->w_floating)) {
|
||||
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);
|
||||
}
|
||||
redraw_later(wp, UPD_SOME_VALID);
|
||||
|
||||
Reference in New Issue
Block a user