Merge #8987 from justinmk/vim-8.1.0373

This commit is contained in:
Justin M. Keyes 2018-09-13 01:51:17 +02:00 committed by GitHub
commit d5702a4534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 185 additions and 170 deletions

View File

@ -104,16 +104,22 @@ static void redraw_for_cursorline(win_T *wp)
if ((wp->w_p_rnu || wp->w_p_cul)
&& (wp->w_valid & VALID_CROW) == 0
&& !pum_visible()) {
if (!wp->w_p_rnu && 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);
last_cursorline = wp->w_cursor.lnum;
if (wp->w_p_rnu) {
// win_line() will redraw the number column only.
redraw_win_later(wp, VALID);
} else {
redraw_win_later(wp, SOME_VALID);
}
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;
}
}
}

View File

@ -509,7 +509,7 @@ void update_single_line(win_T *wp, linenr_T lnum)
start_search_hl();
prepare_search_hl(wp, lnum);
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();
break;
}
@ -1233,15 +1233,13 @@ static void win_update(win_T *wp)
* with. It is used further down when the line doesn't fit. */
srow = row;
/*
* Update a line when it is in an area that needs updating, when it
* has changes or w_lines[idx] is invalid.
* bot_start may be halfway through a wrapped line after using
* win_del_lines(), check if the current line includes it.
* When syntax folding is being used, the saved syntax states will
* already have been updated, we can't see where the syntax state is
* the same again, just update until the end of the window.
*/
// Update a line when it is in an area that needs updating, when it
// has changes or w_lines[idx] is invalid.
// "bot_start" may be halfway a wrapped line after using
// win_del_lines(), check if the current line includes it.
// When syntax folding is being used, the saved syntax states will
// already have been updated, we can't see where the syntax state is
// the same again, just update until the end of the window.
if (row < top_end
|| (row >= mid_start && row < mid_end)
|| top_to_mod
@ -1439,7 +1437,7 @@ static void win_update(win_T *wp)
/*
* 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_lastlnum = lnum;
@ -1466,7 +1464,13 @@ static void win_update(win_T *wp)
++idx;
lnum += fold_count + 1;
} 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;
if (row > wp->w_height) /* past end of screen */
break;
@ -2110,7 +2114,8 @@ win_line (
linenr_T lnum,
int startrow,
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
@ -2254,156 +2259,160 @@ win_line (
row = startrow;
screen_row = row + wp->w_winrow;
/*
* To speed up the loop below, set extra_check when there is linebreak,
* trailing white space and/or syntax processing to be done.
*/
extra_check = wp->w_p_lbr;
if (syntax_present(wp) && !wp->w_s->b_syn_error) {
/* Prepare for syntax highlighting in this line. When there is an
* error, stop syntax highlighting. */
save_did_emsg = did_emsg;
did_emsg = FALSE;
syntax_start(wp, lnum);
if (did_emsg)
wp->w_s->b_syn_error = TRUE;
else {
did_emsg = save_did_emsg;
has_syntax = TRUE;
extra_check = TRUE;
}
}
if (bufhl_start_line(wp->w_buffer, lnum, &bufhl_info)) {
has_bufhl = true;
extra_check = true;
}
/* Check for columns to display for 'colorcolumn'. */
color_cols = wp->w_buffer->terminal ? NULL : wp->w_p_cc_cols;
if (color_cols != NULL)
draw_color_col = advance_color_col(VCOL_HLC, &color_cols);
if (wp->w_p_spell
&& *wp->w_s->b_p_spl != NUL
&& !GA_EMPTY(&wp->w_s->b_langp)
&& *(char **)(wp->w_s->b_langp.ga_data) != NULL) {
/* Prepare for spell checking. */
has_spell = true;
extra_check = TRUE;
/* Get the start of the next line, so that words that wrap to the next
* line are found too: "et<line-break>al.".
* Trick: skip a few chars for C/shell/Vim comments */
nextline[SPWORDLEN] = NUL;
if (lnum < wp->w_buffer->b_ml.ml_line_count) {
line = ml_get_buf(wp->w_buffer, lnum + 1, FALSE);
spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
}
/* When a word wrapped from the previous line the start of the current
* line is valid. */
if (lnum == checked_lnum)
cur_checked_col = checked_col;
checked_lnum = 0;
/* When there was a sentence end in the previous line may require a
* word starting with capital in this line. In line 1 always check
* the first word. */
if (lnum != capcol_lnum)
cap_col = -1;
if (lnum == 1)
cap_col = 0;
capcol_lnum = 0;
}
/*
* handle visual active in this window
*/
fromcol = -10;
tocol = MAXCOL;
if (VIsual_active && wp->w_buffer == curwin->w_buffer) {
/* Visual is after curwin->w_cursor */
if (ltoreq(curwin->w_cursor, VIsual)) {
top = &curwin->w_cursor;
bot = &VIsual;
} else { /* Visual is before curwin->w_cursor */
top = &VIsual;
bot = &curwin->w_cursor;
}
lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum);
if (VIsual_mode == Ctrl_V) { /* block mode */
if (lnum_in_visual_area) {
fromcol = wp->w_old_cursor_fcol;
tocol = wp->w_old_cursor_lcol;
if (!number_only) {
// To speed up the loop below, set extra_check when there is linebreak,
// trailing white space and/or syntax processing to be done.
extra_check = wp->w_p_lbr;
if (syntax_present(wp) && !wp->w_s->b_syn_error) {
// Prepare for syntax highlighting in this line. When there is an
// error, stop syntax highlighting.
save_did_emsg = did_emsg;
did_emsg = false;
syntax_start(wp, lnum);
if (did_emsg) {
wp->w_s->b_syn_error = true;
} else {
did_emsg = save_did_emsg;
has_syntax = true;
extra_check = true;
}
} else { /* non-block mode */
if (lnum > top->lnum && lnum <= bot->lnum)
fromcol = 0;
else if (lnum == top->lnum) {
if (VIsual_mode == 'V') /* linewise */
fromcol = 0;
else {
getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL);
if (gchar_pos(top) == NUL)
tocol = fromcol + 1;
}
if (bufhl_start_line(wp->w_buffer, lnum, &bufhl_info)) {
has_bufhl = true;
extra_check = true;
}
// Check for columns to display for 'colorcolumn'.
color_cols = wp->w_buffer->terminal ? NULL : wp->w_p_cc_cols;
if (color_cols != NULL) {
draw_color_col = advance_color_col(VCOL_HLC, &color_cols);
}
if (wp->w_p_spell
&& *wp->w_s->b_p_spl != NUL
&& !GA_EMPTY(&wp->w_s->b_langp)
&& *(char **)(wp->w_s->b_langp.ga_data) != NULL) {
// Prepare for spell checking.
has_spell = true;
extra_check = true;
// Get the start of the next line, so that words that wrap to the next
// line are found too: "et<line-break>al.".
// Trick: skip a few chars for C/shell/Vim comments
nextline[SPWORDLEN] = NUL;
if (lnum < wp->w_buffer->b_ml.ml_line_count) {
line = ml_get_buf(wp->w_buffer, lnum + 1, false);
spell_cat_line(nextline + SPWORDLEN, line, SPWORDLEN);
}
// When a word wrapped from the previous line the start of the current
// line is valid.
if (lnum == checked_lnum) {
cur_checked_col = checked_col;
}
checked_lnum = 0;
// When there was a sentence end in the previous line may require a
// word starting with capital in this line. In line 1 always check
// the first word.
if (lnum != capcol_lnum) {
cap_col = -1;
}
if (lnum == 1) {
cap_col = 0;
}
capcol_lnum = 0;
}
//
// handle visual active in this window
//
fromcol = -10;
tocol = MAXCOL;
if (VIsual_active && wp->w_buffer == curwin->w_buffer) {
// Visual is after curwin->w_cursor
if (ltoreq(curwin->w_cursor, VIsual)) {
top = &curwin->w_cursor;
bot = &VIsual;
} else { // Visual is before curwin->w_cursor
top = &VIsual;
bot = &curwin->w_cursor;
}
lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum);
if (VIsual_mode == Ctrl_V) { // block mode
if (lnum_in_visual_area) {
fromcol = wp->w_old_cursor_fcol;
tocol = wp->w_old_cursor_lcol;
}
}
if (VIsual_mode != 'V' && lnum == bot->lnum) {
if (*p_sel == 'e' && bot->col == 0
&& bot->coladd == 0
) {
fromcol = -10;
tocol = MAXCOL;
} else if (bot->col == MAXCOL)
tocol = MAXCOL;
else {
pos = *bot;
if (*p_sel == 'e')
getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL);
else {
getvvcol(wp, &pos, NULL, NULL, (colnr_T *)&tocol);
++tocol;
} else { // non-block mode
if (lnum > top->lnum && lnum <= bot->lnum) {
fromcol = 0;
} else if (lnum == top->lnum) {
if (VIsual_mode == 'V') { // linewise
fromcol = 0;
} else {
getvvcol(wp, top, (colnr_T *)&fromcol, NULL, NULL);
if (gchar_pos(top) == NUL) {
tocol = fromcol + 1;
}
}
}
if (VIsual_mode != 'V' && lnum == bot->lnum) {
if (*p_sel == 'e' && bot->col == 0
&& bot->coladd == 0) {
fromcol = -10;
tocol = MAXCOL;
} else if (bot->col == MAXCOL) {
tocol = MAXCOL;
} else {
pos = *bot;
if (*p_sel == 'e') {
getvvcol(wp, &pos, (colnr_T *)&tocol, NULL, NULL);
} else {
getvvcol(wp, &pos, NULL, NULL, (colnr_T *)&tocol);
tocol++;
}
}
}
}
}
/* Check if the character under the cursor should not be inverted */
if (!highlight_match && lnum == curwin->w_cursor.lnum && wp == curwin
)
noinvcur = TRUE;
// Check if the character under the cursor should not be inverted
if (!highlight_match && lnum == curwin->w_cursor.lnum && wp == curwin) {
noinvcur = true;
}
/* if inverting in this line set area_highlighting */
if (fromcol >= 0) {
// if inverting in this line set area_highlighting
if (fromcol >= 0) {
area_highlighting = true;
attr = win_hl_attr(wp, HLF_V);
}
// handle 'incsearch' and ":s///c" highlighting
} else if (highlight_match
&& wp == curwin
&& lnum >= curwin->w_cursor.lnum
&& lnum <= curwin->w_cursor.lnum + search_match_lines) {
if (lnum == curwin->w_cursor.lnum) {
getvcol(curwin, &(curwin->w_cursor),
(colnr_T *)&fromcol, NULL, NULL);
} else {
fromcol = 0;
}
if (lnum == curwin->w_cursor.lnum + search_match_lines) {
pos.lnum = lnum;
pos.col = search_match_endcol;
getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
} else {
tocol = MAXCOL;
}
// do at least one character; happens when past end of line
if (fromcol == tocol) {
tocol = fromcol + 1;
}
area_highlighting = true;
attr = win_hl_attr(wp, HLF_V);
attr = win_hl_attr(wp, HLF_I);
}
}
/*
* handle 'incsearch' and ":s///c" highlighting
*/
else if (highlight_match
&& wp == curwin
&& lnum >= curwin->w_cursor.lnum
&& lnum <= curwin->w_cursor.lnum + search_match_lines) {
if (lnum == curwin->w_cursor.lnum)
getvcol(curwin, &(curwin->w_cursor),
(colnr_T *)&fromcol, NULL, NULL);
else
fromcol = 0;
if (lnum == curwin->w_cursor.lnum + search_match_lines) {
pos.lnum = lnum;
pos.col = search_match_endcol;
getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
} else
tocol = MAXCOL;
/* do at least one character; happens when past end of line */
if (fromcol == tocol)
tocol = fromcol + 1;
area_highlighting = true;
attr = win_hl_attr(wp, HLF_I);
}
filler_lines = diff_check(wp, lnum);
if (filler_lines < 0) {
@ -2464,7 +2473,7 @@ win_line (
line = ml_get_buf(wp->w_buffer, lnum, FALSE);
ptr = line;
if (has_spell) {
if (has_spell && !number_only) {
// For checking first word with a capital skip white space.
if (cap_col == 0) {
cap_col = (int)getwhitecols(line);
@ -2517,7 +2526,7 @@ win_line (
v = wp->w_skipcol;
else
v = wp->w_leftcol;
if (v > 0) {
if (v > 0 && !number_only) {
char_u *prev_ptr = ptr;
while (vcol < v && *ptr != NUL) {
c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
@ -2626,7 +2635,7 @@ win_line (
*/
cur = wp->w_match_head;
shl_flag = false;
while (cur != NULL || !shl_flag) {
while ((cur != NULL || !shl_flag) && !number_only) {
if (!shl_flag) {
shl = &search_hl;
shl_flag = true;
@ -2895,11 +2904,11 @@ win_line (
}
}
/* When still displaying '$' of change command, stop at cursor */
if (dollar_vcol >= 0 && wp == curwin
&& lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol
&& filler_todo <= 0
) {
// When still displaying '$' of change command, stop at cursor
if ((dollar_vcol >= 0 && wp == curwin
&& lnum == wp->w_cursor.lnum && vcol >= (long)wp->w_virtcol
&& 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,
wp->w_hl_attr_normal, false);
// Pretend we have finished updating the window. Except when