vim-patch:8.2.0035: saving and restoring called_emsg is clumsy (#19335)

Problem:    Saving and restoring called_emsg is clumsy.
Solution:   Count the number of error messages.
53989554a4
This commit is contained in:
zeertzjq
2022-07-13 04:08:49 +08:00
committed by GitHub
parent b1e0197a14
commit 39d51c833a
10 changed files with 26 additions and 49 deletions

View File

@@ -398,7 +398,7 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
linenr_T l;
colnr_T matchcol;
long nmatched = 0;
int save_called_emsg = called_emsg;
const int called_emsg_before = called_emsg;
// for :{range}s/pat only highlight inside the range
if (lnum < search_first_line || lnum > search_last_line) {
@@ -421,7 +421,6 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
// Repeat searching for a match until one is found that includes "mincol"
// or none is found in this line.
called_emsg = false;
for (;;) {
// Stop searching after passing the time limit.
if (profile_passed_limit(shl->tm)) {
@@ -468,7 +467,7 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
if (regprog_is_copy) {
cur->match.regprog = cur->hl.rm.regprog;
}
if (called_emsg || got_int || timed_out) {
if (called_emsg > called_emsg_before || got_int || timed_out) {
// Error while handling regexp: stop using this regexp.
if (shl == search_hl) {
// don't free regprog in the match list, it's a copy
@@ -495,9 +494,6 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
break; // useful match found
}
}
// Restore called_emsg for assert_fails().
called_emsg = save_called_emsg;
}
/// Advance to the match in window "wp" line "lnum" or past it.