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)
11a58af66f
This commit is contained in:
zeertzjq 2021-07-31 17:59:33 +08:00
parent 56b437a6c7
commit 68f0670dfc
3 changed files with 24 additions and 21 deletions

View File

@ -290,14 +290,21 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume,
set_topline(wp, wp->w_topline); set_topline(wp, wp->w_topline);
} }
// Relative numbering may require updating more. Cursor line // Relative numbering may require updating more.
// highlighting probably needs to be updated if it's below the if (wp->w_p_rnu) {
// 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))) {
redraw_later(wp, SOME_VALID); 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);
}
}
} }
} }

View File

@ -1275,25 +1275,19 @@ static void normal_redraw(NormalState *s)
redrawWinline(curwin, curwin->w_cursor.lnum); redrawWinline(curwin, curwin->w_cursor.lnum);
} }
if (curwin->w_p_cul && curwin->w_p_wrap // Might need to update for 'cursorline'.
&& (curwin->w_p_culopt_flags & CULOPT_SCRLINE)) { // When 'cursorlineopt' is "screenline" need to redraw always.
must_redraw = NOT_VALID; 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) { if (VIsual_active) {
update_curbuf(INVERTED); // update inverted part update_curbuf(INVERTED); // update inverted part
} else if (must_redraw) { } else if (must_redraw) {
// Might need some more update for the cursorscreen line. update_screen(0);
// 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);
}
} else if (redraw_cmdline || clear_cmdline) { } else if (redraw_cmdline || clear_cmdline) {
showmode(); showmode();
} }

View File

@ -1371,7 +1371,9 @@ static void win_update(win_T *wp, Providers *providers)
// match in fixed position might need redraw // match in fixed position might need redraw
// if lines were inserted or deleted // if lines were inserted or deleted
|| (wp->w_match_head != NULL || (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) { if (lnum == mod_top) {
top_to_mod = false; top_to_mod = false;
} }