diff options
-rw-r--r-- | src/nvim/search.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index 578d1fd35a..ec13584013 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1563,7 +1563,6 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) int hash_dir = 0; /* Direction searched for # things */ int comment_dir = 0; /* Direction searched for comments */ pos_T match_pos; /* Where last slash-star was found */ - int start_in_quotes; /* start position is in quotes */ int traveled = 0; /* how far we've searched so far */ int ignore_cend = FALSE; /* ignore comment end */ int cpo_match; /* vi compatible matching */ @@ -1754,7 +1753,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) backwards = !backwards; do_quotes = -1; - start_in_quotes = MAYBE; + TriState start_in_quotes = kNone; clearpos(&match_pos); /* backward search: Check if this line contains a single-line comment */ @@ -1928,23 +1927,26 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) inquote = FALSE; if (ptr[-1] == '\\') { do_quotes = 1; - if (start_in_quotes == MAYBE) { - /* Do we need to use at_start here? */ + if (start_in_quotes == kNone) { + // Do we need to use at_start here? inquote = TRUE; - start_in_quotes = TRUE; - } else if (backwards) + start_in_quotes = kTrue; + } else if (backwards) { inquote = TRUE; + } } if (pos.lnum > 1) { ptr = ml_get(pos.lnum - 1); if (*ptr && *(ptr + STRLEN(ptr) - 1) == '\\') { do_quotes = 1; - if (start_in_quotes == MAYBE) { + if (start_in_quotes == kNone) { inquote = at_start; - if (inquote) - start_in_quotes = TRUE; - } else if (!backwards) + if (inquote) { + start_in_quotes = kTrue; + } + } else if (!backwards) { inquote = TRUE; + } } /* ml_get() only keeps one line, need to get linep again */ @@ -1952,8 +1954,9 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) } } } - if (start_in_quotes == MAYBE) - start_in_quotes = FALSE; + if (start_in_quotes == kNone) { + start_in_quotes = kFalse; + } /* * If 'smartmatch' is set: @@ -1972,7 +1975,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) /* at end of line without trailing backslash, reset inquote */ if (pos.col == 0 || linep[pos.col - 1] != '\\') { inquote = FALSE; - start_in_quotes = FALSE; + start_in_quotes = kFalse; } break; @@ -1987,7 +1990,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) break; if ((((int)pos.col - 1 - col) & 1) == 0) { inquote = !inquote; - start_in_quotes = FALSE; + start_in_quotes = kFalse; } } break; @@ -2039,7 +2042,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel) /* Check for match outside of quotes, and inside of * quotes when the start is also inside of quotes. */ - if ((!inquote || start_in_quotes == TRUE) + if ((!inquote || start_in_quotes == kTrue) && (c == initc || c == findc)) { int col, bslcnt = 0; |