mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.0374: moving the cursor is slow when 'relativenumber' is set
Problem: Moving the cursor is slow when 'relativenumber' is set.
Solution: Only redraw the number column, not all lines.
bd9a53c06c
This commit is contained in:
parent
e7a9c76ab0
commit
ba27284f07
@ -104,17 +104,23 @@ static void redraw_for_cursorline(win_T *wp)
|
|||||||
if ((wp->w_p_rnu || wp->w_p_cul)
|
if ((wp->w_p_rnu || wp->w_p_cul)
|
||||||
&& (wp->w_valid & VALID_CROW) == 0
|
&& (wp->w_valid & VALID_CROW) == 0
|
||||||
&& !pum_visible()) {
|
&& !pum_visible()) {
|
||||||
if (!wp->w_p_rnu && wp->w_redr_type <= VALID && last_cursorline != 0) {
|
if (wp->w_p_rnu) {
|
||||||
// "last_cursorline" may be set for another window, worst case we
|
// win_line() will redraw the number column only.
|
||||||
// redraw too much. This is optimized for moving the cursor around
|
|
||||||
// in the same window.
|
|
||||||
redrawWinline(wp, last_cursorline, false);
|
|
||||||
redrawWinline(wp, wp->w_cursor.lnum, false);
|
|
||||||
redraw_win_later(wp, VALID);
|
redraw_win_later(wp, VALID);
|
||||||
} else {
|
|
||||||
redraw_win_later(wp, SOME_VALID);
|
|
||||||
}
|
}
|
||||||
last_cursorline = wp->w_cursor.lnum;
|
if (wp->w_p_cul) {
|
||||||
|
if (wp->w_redr_type <= VALID && last_cursorline != 0) {
|
||||||
|
// "last_cursorline" may be set for another window, worst case
|
||||||
|
// we redraw too much. This is optimized for moving the cursor
|
||||||
|
// around in the same window.
|
||||||
|
redrawWinline(wp, last_cursorline, false);
|
||||||
|
redrawWinline(wp, wp->w_cursor.lnum, false);
|
||||||
|
redraw_win_later(wp, VALID);
|
||||||
|
} else {
|
||||||
|
redraw_win_later(wp, SOME_VALID);
|
||||||
|
}
|
||||||
|
last_cursorline = wp->w_cursor.lnum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ void update_single_line(win_T *wp, linenr_T lnum)
|
|||||||
start_search_hl();
|
start_search_hl();
|
||||||
prepare_search_hl(wp, lnum);
|
prepare_search_hl(wp, lnum);
|
||||||
update_window_hl(wp, false);
|
update_window_hl(wp, false);
|
||||||
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, false);
|
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, false, false);
|
||||||
end_search_hl();
|
end_search_hl();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1233,15 +1233,13 @@ static void win_update(win_T *wp)
|
|||||||
* with. It is used further down when the line doesn't fit. */
|
* with. It is used further down when the line doesn't fit. */
|
||||||
srow = row;
|
srow = row;
|
||||||
|
|
||||||
/*
|
// Update a line when it is in an area that needs updating, when it
|
||||||
* Update a line when it is in an area that needs updating, when it
|
// has changes or w_lines[idx] is invalid.
|
||||||
* has changes or w_lines[idx] is invalid.
|
// "bot_start" may be halfway a wrapped line after using
|
||||||
* bot_start may be halfway through a wrapped line after using
|
// win_del_lines(), check if the current line includes it.
|
||||||
* win_del_lines(), check if the current line includes it.
|
// When syntax folding is being used, the saved syntax states will
|
||||||
* When syntax folding is being used, the saved syntax states will
|
// already have been updated, we can't see where the syntax state is
|
||||||
* already have been updated, we can't see where the syntax state is
|
// the same again, just update until the end of the window.
|
||||||
* the same again, just update until the end of the window.
|
|
||||||
*/
|
|
||||||
if (row < top_end
|
if (row < top_end
|
||||||
|| (row >= mid_start && row < mid_end)
|
|| (row >= mid_start && row < mid_end)
|
||||||
|| top_to_mod
|
|| top_to_mod
|
||||||
@ -1439,7 +1437,7 @@ static void win_update(win_T *wp)
|
|||||||
/*
|
/*
|
||||||
* Display one line.
|
* Display one line.
|
||||||
*/
|
*/
|
||||||
row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0);
|
row = win_line(wp, lnum, srow, wp->w_height, mod_top == 0, false);
|
||||||
|
|
||||||
wp->w_lines[idx].wl_folded = FALSE;
|
wp->w_lines[idx].wl_folded = FALSE;
|
||||||
wp->w_lines[idx].wl_lastlnum = lnum;
|
wp->w_lines[idx].wl_lastlnum = lnum;
|
||||||
@ -1466,7 +1464,13 @@ static void win_update(win_T *wp)
|
|||||||
++idx;
|
++idx;
|
||||||
lnum += fold_count + 1;
|
lnum += fold_count + 1;
|
||||||
} else {
|
} else {
|
||||||
/* This line does not need updating, advance to the next one */
|
if (wp->w_p_rnu) {
|
||||||
|
// 'relativenumber' set: The text doesn't need to be drawn, but
|
||||||
|
// the number column nearly always does.
|
||||||
|
(void)win_line(wp, lnum, srow, wp->w_height, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This line does not need to be drawn, advance to the next one.
|
||||||
row += wp->w_lines[idx++].wl_size;
|
row += wp->w_lines[idx++].wl_size;
|
||||||
if (row > wp->w_height) /* past end of screen */
|
if (row > wp->w_height) /* past end of screen */
|
||||||
break;
|
break;
|
||||||
@ -2110,7 +2114,8 @@ win_line (
|
|||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
int startrow,
|
int startrow,
|
||||||
int endrow,
|
int endrow,
|
||||||
bool nochange /* not updating for changed text */
|
bool nochange, // not updating for changed text
|
||||||
|
bool number_only // only update the number column
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned off; // offset in ScreenLines/ScreenAttrs
|
unsigned off; // offset in ScreenLines/ScreenAttrs
|
||||||
@ -2254,10 +2259,9 @@ win_line (
|
|||||||
row = startrow;
|
row = startrow;
|
||||||
screen_row = row + wp->w_winrow;
|
screen_row = row + wp->w_winrow;
|
||||||
|
|
||||||
/*
|
if (!number_only) {
|
||||||
* To speed up the loop below, set extra_check when there is linebreak,
|
// To speed up the loop below, set extra_check when there is linebreak,
|
||||||
* trailing white space and/or syntax processing to be done.
|
// trailing white space and/or syntax processing to be done.
|
||||||
*/
|
|
||||||
extra_check = wp->w_p_lbr;
|
extra_check = wp->w_p_lbr;
|
||||||
if (syntax_present(wp) && !wp->w_s->b_syn_error) {
|
if (syntax_present(wp) && !wp->w_s->b_syn_error) {
|
||||||
/* Prepare for syntax highlighting in this line. When there is an
|
/* Prepare for syntax highlighting in this line. When there is an
|
||||||
@ -2404,6 +2408,7 @@ win_line (
|
|||||||
area_highlighting = true;
|
area_highlighting = true;
|
||||||
attr = win_hl_attr(wp, HLF_I);
|
attr = win_hl_attr(wp, HLF_I);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
filler_lines = diff_check(wp, lnum);
|
filler_lines = diff_check(wp, lnum);
|
||||||
if (filler_lines < 0) {
|
if (filler_lines < 0) {
|
||||||
@ -2464,7 +2469,7 @@ win_line (
|
|||||||
line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
||||||
ptr = line;
|
ptr = line;
|
||||||
|
|
||||||
if (has_spell) {
|
if (has_spell && !number_only) {
|
||||||
// For checking first word with a capital skip white space.
|
// For checking first word with a capital skip white space.
|
||||||
if (cap_col == 0) {
|
if (cap_col == 0) {
|
||||||
cap_col = (int)getwhitecols(line);
|
cap_col = (int)getwhitecols(line);
|
||||||
@ -2517,7 +2522,7 @@ win_line (
|
|||||||
v = wp->w_skipcol;
|
v = wp->w_skipcol;
|
||||||
else
|
else
|
||||||
v = wp->w_leftcol;
|
v = wp->w_leftcol;
|
||||||
if (v > 0) {
|
if (v > 0 && !number_only) {
|
||||||
char_u *prev_ptr = ptr;
|
char_u *prev_ptr = ptr;
|
||||||
while (vcol < v && *ptr != NUL) {
|
while (vcol < v && *ptr != NUL) {
|
||||||
c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
|
c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
|
||||||
@ -2626,7 +2631,7 @@ win_line (
|
|||||||
*/
|
*/
|
||||||
cur = wp->w_match_head;
|
cur = wp->w_match_head;
|
||||||
shl_flag = false;
|
shl_flag = false;
|
||||||
while (cur != NULL || !shl_flag) {
|
while ((cur != NULL || !shl_flag) && !number_only) {
|
||||||
if (!shl_flag) {
|
if (!shl_flag) {
|
||||||
shl = &search_hl;
|
shl = &search_hl;
|
||||||
shl_flag = true;
|
shl_flag = true;
|
||||||
@ -2895,11 +2900,11 @@ win_line (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When still displaying '$' of change command, stop at cursor */
|
// When still displaying '$' of change command, stop at cursor
|
||||||
if (dollar_vcol >= 0 && wp == curwin
|
if ((dollar_vcol >= 0 && wp == curwin
|
||||||
&& lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol
|
&& lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol
|
||||||
&& filler_todo <= 0
|
&& filler_todo <= 0)
|
||||||
) {
|
|| (number_only && draw_state > WL_NR)) {
|
||||||
screen_line(screen_row, wp->w_wincol, col, -wp->w_width, wp->w_p_rl, wp,
|
screen_line(screen_row, wp->w_wincol, col, -wp->w_width, wp->w_p_rl, wp,
|
||||||
wp->w_hl_attr_normal, false);
|
wp->w_hl_attr_normal, false);
|
||||||
// Pretend we have finished updating the window. Except when
|
// Pretend we have finished updating the window. Except when
|
||||||
|
Loading…
Reference in New Issue
Block a user