diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-04-27 05:27:31 +0200 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-02 13:11:47 +0200 |
commit | 5e4df766f6e428659221f8eae144e9ed18574f8d (patch) | |
tree | 4e06071a57a88ef1725e05f9526417f5291bd3ce /src/nvim/move.c | |
parent | 88d13d2778a4fab3fdcc2bf4c1adf631b38ea3ce (diff) | |
download | rneovim-5e4df766f6e428659221f8eae144e9ed18574f8d.tar.gz rneovim-5e4df766f6e428659221f8eae144e9ed18574f8d.tar.bz2 rneovim-5e4df766f6e428659221f8eae144e9ed18574f8d.zip |
vim-patch:9.0.0892: may redraw when not needed
Problem: May redraw when not needed, causing slow scrolling.
Solution: Do not redraw when w_skipcol doesn't change. When w_skipcol
changes only redraw from the top. (issue vim/vim#11559)
https://github.com/vim/vim/commit/f32fb93e431e4db95a8663d86dfeb6bffa5896f6
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/move.c')
-rw-r--r-- | src/nvim/move.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index f245890e40..cc8497f544 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -164,6 +164,19 @@ static void redraw_for_cursorcolumn(win_T *wp) } } +/// Set wp->s_skipcol to zero and redraw later if needed. +static void reset_skipcol(win_T *wp) +{ + if (wp->w_skipcol != 0) { + wp->w_skipcol = 0; + + // Should use the least expensive way that displays all that changed. + // UPD_NOT_VALID is too expensive, UPD_REDRAW_TOP does not redraw + // enough when the top line gets another screen line. + redraw_later(wp, UPD_SOME_VALID); + } +} + // Update curwin->w_topline to move the cursor onto the screen. void update_topline(win_T *wp) { @@ -360,12 +373,9 @@ void update_topline(win_T *wp) if (wp->w_topline != old_topline || wp->w_topfill != old_topfill) { dollar_vcol = -1; - if (wp->w_skipcol != 0) { - wp->w_skipcol = 0; - redraw_later(wp, UPD_NOT_VALID); - } else { - redraw_later(wp, UPD_VALID); - } + redraw_later(wp, UPD_VALID); + reset_skipcol(wp); + // May need to set w_skipcol when cursor in w_topline. if (wp->w_cursor.lnum == wp->w_topline) { validate_cursor(); @@ -983,7 +993,7 @@ void curs_columns(win_T *wp, int may_scroll) wp->w_skipcol = 0; } if (prev_skipcol != wp->w_skipcol) { - redraw_later(wp, UPD_NOT_VALID); + redraw_later(wp, UPD_SOME_VALID); } redraw_for_cursorcolumn(wp); @@ -1429,10 +1439,7 @@ void adjust_skipcol(void) validate_cheight(); if (curwin->w_cline_height == curwin->w_height) { // the line just fits in the window, don't scroll - if (curwin->w_skipcol != 0) { - curwin->w_skipcol = 0; - redraw_later(curwin, UPD_NOT_VALID); - } + reset_skipcol(curwin); return; } @@ -1758,8 +1765,7 @@ void scroll_cursor_top(int min_scroll, int always) check_topfill(curwin, false); // TODO(vim): if the line doesn't fit may optimize w_skipcol if (curwin->w_topline == curwin->w_cursor.lnum) { - curwin->w_skipcol = 0; - redraw_later(curwin, UPD_NOT_VALID); + reset_skipcol(curwin); } if (curwin->w_topline != old_topline || curwin->w_skipcol != old_skipcol @@ -2115,7 +2121,7 @@ void cursor_correct(void) // 'smoothscroll is active if (curwin->w_cline_height == curwin->w_height) { // The cursor line just fits in the window, don't scroll. - curwin->w_skipcol = 0; + reset_skipcol(curwin); return; } // TODO(vim): If the cursor line doesn't fit in the window then only adjust w_skipcol. |