diff options
author | zeertzjq <zeertzjq@outlook.com> | 2021-07-31 17:59:33 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2021-08-02 05:41:17 +0800 |
commit | 68f0670dfca1dd4308815792cc09f0112d288b6d (patch) | |
tree | 4010832453b3573ad1c18d582d1766353b827103 /src | |
parent | 56b437a6c7a050921653a0d9e091777682db31ea (diff) | |
download | rneovim-68f0670dfca1dd4308815792cc09f0112d288b6d.tar.gz rneovim-68f0670dfca1dd4308815792cc09f0112d288b6d.tar.bz2 rneovim-68f0670dfca1dd4308815792cc09f0112d288b6d.zip |
vim-patch:8.1.2214: too much is redrawn when 'cursorline' is set
Problem: Too much is redrawn when 'cursorline' is set.
Solution: Don't do a complete redraw. (closes vim/vim#5079)
https://github.com/vim/vim/commit/11a58af66fa5c442f0a22c5d59beabf187ed4e89
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/change.c | 19 | ||||
-rw-r--r-- | src/nvim/normal.c | 22 | ||||
-rw-r--r-- | src/nvim/screen.c | 4 |
3 files changed, 24 insertions, 21 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index fa813ef75c..49e403425a 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -290,14 +290,21 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, set_topline(wp, wp->w_topline); } - // Relative numbering may require updating more. Cursor line - // highlighting probably needs to be updated if it's below the - // change (or is using screenline highlighting). - if (wp->w_p_rnu - || ((wp->w_p_cul && lnum <= wp->w_last_cursorline) - || (wp->w_p_culopt_flags & CULOPT_SCRLINE))) { + // Relative numbering may require updating more. + if (wp->w_p_rnu) { redraw_later(wp, SOME_VALID); } + + // Cursor line highlighting probably need to be updated with + // "VALID" if it's below the change. + // If the cursor line is inside the change we need to redraw more. + if (wp->w_p_cul) { + if (xtra == 0) { + redraw_later(wp, VALID); + } else if (lnum <= wp->w_last_cursorline) { + redraw_later(wp, SOME_VALID); + } + } } } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 1471c16a9f..54ca216a53 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1275,25 +1275,19 @@ static void normal_redraw(NormalState *s) redrawWinline(curwin, curwin->w_cursor.lnum); } - if (curwin->w_p_cul && curwin->w_p_wrap - && (curwin->w_p_culopt_flags & CULOPT_SCRLINE)) { - must_redraw = NOT_VALID; + // Might need to update for 'cursorline'. + // When 'cursorlineopt' is "screenline" need to redraw always. + if (curwin->w_p_cul + && (curwin->w_last_cursorline != curwin->w_cursor.lnum + || (curwin->w_p_culopt_flags & CULOPT_SCRLINE)) + && !char_avail()) { + redraw_later(curwin, VALID); } if (VIsual_active) { update_curbuf(INVERTED); // update inverted part } else if (must_redraw) { - // Might need some more update for the cursorscreen line. - // TODO(vim): can we optimized this? - if (curwin->w_p_cul - && curwin->w_p_wrap - && (curwin->w_p_culopt_flags & CULOPT_SCRLINE) - && !char_avail()) { - update_screen(VALID); - } - else { - update_screen(0); - } + update_screen(0); } else if (redraw_cmdline || clear_cmdline) { showmode(); } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 6fda44f5eb..1e81fc691d 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1371,7 +1371,9 @@ static void win_update(win_T *wp, Providers *providers) // match in fixed position might need redraw // if lines were inserted or deleted || (wp->w_match_head != NULL - && buf->b_mod_xlines != 0)))))) { + && buf->b_mod_xlines != 0))))) + || (wp->w_p_cul && (lnum == wp->w_cursor.lnum + || lnum == wp->w_last_cursorline))) { if (lnum == mod_top) { top_to_mod = false; } |