Mercurial > vim
diff src/search.c @ 14131:ec85acd49b8e v8.1.0083
patch 8.1.0083: "is" and "as" have trouble with quoted punctuation
commit https://github.com/vim/vim/commit/8516071124dbb7ad7caa43cc98ae3c57ae093c9e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 19 18:27:41 2018 +0200
patch 8.1.0083: "is" and "as" have trouble with quoted punctuation
Problem: "is" and "as" have trouble with quoted punctuation.
Solution: Check for punctuation before a quote. (Jason Franklin)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 19 Jun 2018 18:30:07 +0200 |
parents | 96933f0ecbd1 |
children | e7f92d1a3fcd |
line wrap: on
line diff
--- a/src/search.c +++ b/src/search.c @@ -2707,10 +2707,11 @@ showmatch( } /* - * findsent(dir, count) - Find the start of the next sentence in direction - * "dir" Sentences are supposed to end in ".", "!" or "?" followed by white - * space or a line break. Also stop at an empty line. - * Return OK if the next sentence was found. + * Find the start of the next sentence, searching in the direction specified + * by the "dir" argument. The cursor is positioned on the start of the next + * sentence when found. If the next sentence is found, return OK. Return FAIL + * otherwise. See ":h sentence" for the precise definition of a "sentence" + * text object. */ int findsent(int dir, long count) @@ -2758,26 +2759,25 @@ findsent(int dir, long count) else if (dir == BACKWARD) decl(&pos); - /* go back to the previous non-blank char */ + // go back to the previous non-white non-punctuation character found_dot = FALSE; - while ((c = gchar_pos(&pos)) == ' ' || c == '\t' || - (dir == BACKWARD && vim_strchr((char_u *)".!?)]\"'", c) != NULL)) + while (c = gchar_pos(&pos), VIM_ISWHITE(c) + || vim_strchr((char_u *)".!?)]\"'", c) != NULL) { - if (vim_strchr((char_u *)".!?", c) != NULL) - { - /* Only skip over a '.', '!' and '?' once. */ - if (found_dot) - break; + tpos = pos; + if (decl(&tpos) == -1 || (LINEEMPTY(tpos.lnum) && dir == FORWARD)) + break; + + if (found_dot) + break; + if (vim_strchr((char_u *) ".!?", c) != NULL) found_dot = TRUE; - } - if (decl(&pos) == -1) + + if (vim_strchr((char_u *) ")]\"'", c) != NULL + && vim_strchr((char_u *) ".!?)]\"'", gchar_pos(&tpos)) == NULL) break; - /* when going forward: Stop in front of empty line */ - if (LINEEMPTY(pos.lnum) && dir == FORWARD) - { - incl(&pos); - goto found; - } + + decl(&pos); } /* remember the line where the search started */