summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-23 22:59:18 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-23 22:59:18 +0100
commit53989554a44caca0964376d60297f08ec257c53c (patch)
tree34d2140d4201e015661344b05ffb4c2d9aed97ff /src/search.c
parent70188f5b23ea7efec7adaf74e0af797d1bb1afe8 (diff)
downloadvim-git-53989554a44caca0964376d60297f08ec257c53c.tar.gz
patch 8.2.0035: saving and restoring called_emsg is clumsyv8.2.0035
Problem: Saving and restoring called_emsg is clumsy. Solution: Count the number of error messages.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/search.c b/src/search.c
index 1a5dc1a42..3b310dc2a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -624,7 +624,7 @@ searchit(
long nmatched;
int submatch = 0;
int first_match = TRUE;
- int save_called_emsg = called_emsg;
+ int called_emsg_before = called_emsg;
#ifdef FEAT_SEARCH_EXTRA
int break_loop = FALSE;
#endif
@@ -654,7 +654,6 @@ searchit(
/*
* find the string
*/
- called_emsg = FALSE;
do // loop for count
{
// When not accepting a match at the start position set "extra_col" to
@@ -745,7 +744,7 @@ searchit(
#endif
);
// Abort searching on an error (e.g., out of stack).
- if (called_emsg
+ if (called_emsg > called_emsg_before
#ifdef FEAT_RELTIME
|| (timed_out != NULL && *timed_out)
#endif
@@ -1055,7 +1054,8 @@ searchit(
* specified, after an interrupt, after a match and after looping
* twice.
*/
- if (!p_ws || stop_lnum != 0 || got_int || called_emsg
+ if (!p_ws || stop_lnum != 0 || got_int
+ || called_emsg > called_emsg_before
#ifdef FEAT_RELTIME
|| (timed_out != NULL && *timed_out)
#endif
@@ -1082,7 +1082,7 @@ searchit(
if (extra_arg != NULL)
extra_arg->sa_wrapped = TRUE;
}
- if (got_int || called_emsg
+ if (got_int || called_emsg > called_emsg_before
#ifdef FEAT_RELTIME
|| (timed_out != NULL && *timed_out)
#endif
@@ -1096,8 +1096,6 @@ searchit(
vim_regfree(regmatch.regprog);
- called_emsg |= save_called_emsg;
-
if (!found) // did not find it
{
if (got_int)
@@ -4799,7 +4797,7 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, int direction)
int nmatched = 0;
int result = -1;
pos_T pos;
- int save_called_emsg = called_emsg;
+ int called_emsg_before = called_emsg;
int flag = 0;
if (pattern == NULL)
@@ -4828,7 +4826,6 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, int direction)
{
// Zero-width pattern should match somewhere, then we can check if
// start and end are in the same position.
- called_emsg = FALSE;
do
{
regmatch.startpos[0].col++;
@@ -4839,7 +4836,7 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, int direction)
} while (direction == FORWARD ? regmatch.startpos[0].col < pos.col
: regmatch.startpos[0].col > pos.col);
- if (!called_emsg)
+ if (called_emsg == called_emsg_before)
{
result = (nmatched != 0
&& regmatch.startpos[0].lnum == regmatch.endpos[0].lnum
@@ -4847,7 +4844,6 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, int direction)
}
}
- called_emsg |= save_called_emsg;
vim_regfree(regmatch.regprog);
return result;
}