vim-patch:8.2.2361: Vim9: no highlight for "s///gc" when using 'opfunc'

Problem:    Vim9: no highlight for "s///gc" when using 'opfunc'.
Solution:   Reset 'lazyredraw' temporarily. (closes vim/vim#7687)
7c886db915
This commit is contained in:
Jan Edmund Lazo
2021-01-16 22:02:14 -05:00
parent 6a01b3fcc3
commit 402f2bda13
3 changed files with 54 additions and 42 deletions

View File

@@ -3693,6 +3693,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
} else { } else {
char_u *orig_line = NULL; char_u *orig_line = NULL;
int len_change = 0; int len_change = 0;
const bool save_p_lz = p_lz;
int save_p_fen = curwin->w_p_fen; int save_p_fen = curwin->w_p_fen;
curwin->w_p_fen = FALSE; curwin->w_p_fen = FALSE;
@@ -3701,6 +3702,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
int temp = RedrawingDisabled; int temp = RedrawingDisabled;
RedrawingDisabled = 0; RedrawingDisabled = 0;
// avoid calling update_screen() in vgetorpeek()
p_lz = false;
if (new_start != NULL) { if (new_start != NULL) {
/* There already was a substitution, we would /* There already was a substitution, we would
* like to show this to the user. We cannot * like to show this to the user. We cannot
@@ -3754,7 +3758,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
/* clear the question */ /* clear the question */
msg_didout = FALSE; /* don't scroll up */ msg_didout = FALSE; /* don't scroll up */
msg_col = 0; msg_col = 0;
gotocmdline(TRUE); gotocmdline(true);
p_lz = save_p_lz;
// restore the line // restore the line
if (orig_line != NULL) { if (orig_line != NULL) {

View File

@@ -3828,7 +3828,7 @@ static void cmd_cursor_goto(int row, int col)
ui_grid_cursor_goto(grid->handle, row, col); ui_grid_cursor_goto(grid->handle, row, col);
} }
void gotocmdline(int clr) void gotocmdline(bool clr)
{ {
if (ui_has(kUICmdline)) { if (ui_has(kUICmdline)) {
return; return;

View File

@@ -4497,9 +4497,9 @@ find_pattern_in_path(
regmatch_T regmatch; regmatch_T regmatch;
regmatch_T incl_regmatch; regmatch_T incl_regmatch;
regmatch_T def_regmatch; regmatch_T def_regmatch;
int matched = FALSE; bool matched = false;
int did_show = FALSE; bool did_show = false;
int found = FALSE; bool found = false;
int i; int i;
char_u *already = NULL; char_u *already = NULL;
char_u *startp = NULL; char_u *startp = NULL;
@@ -4611,7 +4611,7 @@ find_pattern_in_path(
} }
MSG_PUTS_TITLE(_("in path ---\n")); MSG_PUTS_TITLE(_("in path ---\n"));
} }
did_show = TRUE; did_show = true;
while (depth_displayed < depth && !got_int) { while (depth_displayed < depth && !got_int) {
++depth_displayed; ++depth_displayed;
for (i = 0; i < depth_displayed; i++) for (i = 0; i < depth_displayed; i++)
@@ -4761,10 +4761,10 @@ search_line:
matched = !STRNCMP(startp, ptr, len); matched = !STRNCMP(startp, ptr, len);
if (matched && define_matched && whole if (matched && define_matched && whole
&& vim_iswordc(startp[len])) && vim_iswordc(startp[len]))
matched = FALSE; matched = false;
} else if (regmatch.regprog != NULL } else if (regmatch.regprog != NULL
&& vim_regexec(&regmatch, line, (colnr_T)(p - line))) { && vim_regexec(&regmatch, line, (colnr_T)(p - line))) {
matched = TRUE; matched = true;
startp = regmatch.startp[0]; startp = regmatch.startp[0];
// Check if the line is not a comment line (unless we are // Check if the line is not a comment line (unless we are
// looking for a define). A line starting with "# define" // looking for a define). A line starting with "# define"
@@ -4789,15 +4789,16 @@ search_line:
if (matched if (matched
&& p[0] == '/' && p[0] == '/'
&& (p[1] == '*' || p[1] == '/')) { && (p[1] == '*' || p[1] == '/')) {
matched = FALSE; matched = false;
/* After "//" all text is comment */ // After "//" all text is comment
if (p[1] == '/') if (p[1] == '/') {
break; break;
++p; }
p++;
} else if (!matched && p[0] == '*' && p[1] == '/') { } else if (!matched && p[0] == '*' && p[1] == '/') {
/* Can find match after "* /". */ // Can find match after "* /".
matched = TRUE; matched = true;
++p; p++;
} }
} }
} }
@@ -4811,7 +4812,7 @@ search_line:
if (depth == -1 && lnum == curwin->w_cursor.lnum) if (depth == -1 && lnum == curwin->w_cursor.lnum)
break; break;
found = TRUE; found = true;
aux = p = startp; aux = p = startp;
if (compl_cont_status & CONT_ADDING) { if (compl_cont_status & CONT_ADDING) {
p += compl_length; p += compl_length;
@@ -4879,9 +4880,10 @@ search_line:
break; break;
} }
} else if (action == ACTION_SHOW_ALL) { } else if (action == ACTION_SHOW_ALL) {
found = TRUE; found = true;
if (!did_show) if (!did_show) {
gotocmdline(TRUE); /* cursor at status line */ gotocmdline(true); // cursor at status line
}
if (curr_fname != prev_fname) { if (curr_fname != prev_fname) {
if (did_show) if (did_show)
msg_putchar('\n'); /* cursor below last one */ msg_putchar('\n'); /* cursor below last one */
@@ -4890,28 +4892,28 @@ search_line:
msg_home_replace_hl(curr_fname); msg_home_replace_hl(curr_fname);
prev_fname = curr_fname; prev_fname = curr_fname;
} }
did_show = TRUE; did_show = true;
if (!got_int) if (!got_int) {
show_pat_in_path(line, type, TRUE, action, show_pat_in_path(line, type, true, action,
(depth == -1) ? NULL : files[depth].fp, (depth == -1) ? NULL : files[depth].fp,
(depth == -1) ? &lnum : &files[depth].lnum, (depth == -1) ? &lnum : &files[depth].lnum,
match_count++); match_count++);
}
/* Set matched flag for this file and all the ones that /* Set matched flag for this file and all the ones that
* include it */ * include it */
for (i = 0; i <= depth; ++i) for (i = 0; i <= depth; ++i)
files[i].matched = TRUE; files[i].matched = TRUE;
} else if (--count <= 0) { } else if (--count <= 0) {
found = TRUE; found = true;
if (depth == -1 && lnum == curwin->w_cursor.lnum if (depth == -1 && lnum == curwin->w_cursor.lnum
&& l_g_do_tagpreview == 0 && l_g_do_tagpreview == 0) {
)
EMSG(_("E387: Match is on current line")); EMSG(_("E387: Match is on current line"));
else if (action == ACTION_SHOW) { } else if (action == ACTION_SHOW) {
show_pat_in_path(line, type, did_show, action, show_pat_in_path(line, type, did_show, action,
(depth == -1) ? NULL : files[depth].fp, (depth == -1) ? NULL : files[depth].fp,
(depth == -1) ? &lnum : &files[depth].lnum, 1L); (depth == -1) ? &lnum : &files[depth].lnum, 1L);
did_show = TRUE; did_show = true;
} else { } else {
/* ":psearch" uses the preview window */ /* ":psearch" uses the preview window */
if (l_g_do_tagpreview != 0) { if (l_g_do_tagpreview != 0) {
@@ -4960,15 +4962,16 @@ search_line:
break; break;
} }
exit_matched: exit_matched:
matched = FALSE; matched = false;
/* look for other matches in the rest of the line if we // look for other matches in the rest of the line if we
* are not at the end of it already */ // are not at the end of it already
if (def_regmatch.regprog == NULL if (def_regmatch.regprog == NULL
&& action == ACTION_EXPAND && action == ACTION_EXPAND
&& !(compl_cont_status & CONT_SOL) && !(compl_cont_status & CONT_SOL)
&& *startp != NUL && *startp != NUL
&& *(p = startp + utfc_ptr2len(startp)) != NUL) && *(p = startp + utfc_ptr2len(startp)) != NUL) {
goto search_line; goto search_line;
}
} }
line_breakcheck(); line_breakcheck();
if (action == ACTION_EXPAND) if (action == ACTION_EXPAND)
@@ -5046,16 +5049,20 @@ fpip_end:
vim_regfree(def_regmatch.regprog); vim_regfree(def_regmatch.regprog);
} }
static void show_pat_in_path(char_u *line, int type, int did_show, int action, FILE *fp, linenr_T *lnum, long count) static void show_pat_in_path(char_u *line, int type, bool did_show, int action,
FILE *fp, linenr_T *lnum, long count)
FUNC_ATTR_NONNULL_ARG(1, 6)
{ {
char_u *p; char_u *p;
if (did_show) if (did_show) {
msg_putchar('\n'); /* cursor below last one */ msg_putchar('\n'); // cursor below last one
else if (!msg_silent) } else if (!msg_silent) {
gotocmdline(TRUE); /* cursor at status line */ gotocmdline(true); // cursor at status line
if (got_int) /* 'q' typed at "--more--" message */ }
if (got_int) { // 'q' typed at "--more--" message
return; return;
}
for (;; ) { for (;; ) {
p = line + STRLEN(line) - 1; p = line + STRLEN(line) - 1;
if (fp != NULL) { if (fp != NULL) {