From 3b2bd8d69e6c0a173562778fae6ece67d9adf52c Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 6 May 2023 17:33:42 +0200 Subject: vim-patch:9.0.1512: inserting lines when scrolling with 'smoothscroll' set Problem: Inserting lines when scrolling with 'smoothscroll' set. Solution: Adjust line height computation for w_skipcol. (Luuk van Baal, closes vim/vim#12350) https://github.com/vim/vim/commit/c8502f9b880b6d23baa4f9d28b60e1ceb442e35f --- src/nvim/drawscreen.c | 7 ++++++- src/nvim/move.c | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index ec5163f37a..7f7c721379 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -2101,7 +2101,12 @@ static void win_update(win_T *wp, DecorProviders *providers) if (hasFoldingWin(wp, l, NULL, &l, true, NULL)) { new_rows++; } else if (l == wp->w_topline) { - new_rows += plines_win_nofill(wp, l, true) + wp->w_topfill; + int n = plines_win_nofill(wp, l, false) + wp->w_topfill; + n = adjust_plines_for_skipcol(wp, n); + if (n > wp->w_height_inner) { + n = wp->w_height_inner; + } + new_rows += n; } else { new_rows += plines_win(wp, l, true); } diff --git a/src/nvim/move.c b/src/nvim/move.c index c93c94f8c5..e09a95af70 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -58,7 +58,7 @@ typedef struct { #endif /// Reduce "n" for the screen lines skipped with "wp->w_skipcol". -static int adjust_plines_for_skipcol(win_T *wp, int n) +int adjust_plines_for_skipcol(win_T *wp, int n) { if (wp->w_skipcol == 0) { return n; @@ -196,7 +196,7 @@ static int skipcol_from_plines(win_T *wp, int plines_off) return skipcol; } -/// Set wp->s_skipcol to zero and redraw later if needed. +/// Set wp->w_skipcol to zero and redraw later if needed. static void reset_skipcol(win_T *wp) { if (wp->w_skipcol != 0) { @@ -2267,7 +2267,7 @@ void cursor_correct(void) } if (curwin->w_p_sms && !curwin->w_p_wrap) { - // 'smoothscroll is active + // 'smoothscroll' is active if (curwin->w_cline_height == curwin->w_height_inner) { // The cursor line just fits in the window, don't scroll. reset_skipcol(curwin); -- cgit From 8e74569d7ee170b8661bdc74d61cf6be95303060 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Sat, 6 May 2023 19:24:45 +0200 Subject: vim-patch:9.0.1513: text scrolls unnecessarily when splitting Problem: Text scrolls unnecessarily when splitting and 'splitkeep' is not "cursor". Solution: Avoid resetting w_skipcol. (Luuk van Baal, closes vim/vim#12334) https://github.com/vim/vim/commit/b926bf47d61360a4ec5e4867714a08d70fd49965 --- src/nvim/window.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim') diff --git a/src/nvim/window.c b/src/nvim/window.c index a15be27f74..fd6755a382 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1616,6 +1616,9 @@ static void win_init(win_T *newp, win_T *oldp, int flags) ? NULL : xstrdup(oldp->w_prevdir); if (*p_spk != 'c') { + if (*p_spk == 't') { + newp->w_skipcol = oldp->w_skipcol; + } newp->w_botline = oldp->w_botline; newp->w_prev_height = oldp->w_height; newp->w_prev_winrow = oldp->w_winrow; @@ -6605,13 +6608,13 @@ void win_set_inner_size(win_T *wp, bool valid_cursor) set_fraction(wp); } } - wp->w_skipcol = 0; wp->w_height_inner = height; win_comp_scroll(wp); // 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_skipcol = 0; scroll_to_fraction(wp, prev_height); } redraw_later(wp, UPD_SOME_VALID); -- cgit