diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-23 18:32:07 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-23 18:50:29 -0400 |
commit | 42428b3f857b6390084540e82c0e89a49fc4452f (patch) | |
tree | 05149e89a9f5e5fed3fc4c3495aad2292c01b11b /src/nvim/search.c | |
parent | 925c153f86908a601a19d0142d8c601cf35df88a (diff) | |
download | rneovim-42428b3f857b6390084540e82c0e89a49fc4452f.tar.gz rneovim-42428b3f857b6390084540e82c0e89a49fc4452f.tar.bz2 rneovim-42428b3f857b6390084540e82c0e89a49fc4452f.zip |
vim-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)
https://github.com/vim/vim/commit/8516071124dbb7ad7caa43cc98ae3c57ae093c9e
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r-- | src/nvim/search.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c index 7be7dc2187..fab0ea4837 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -2211,12 +2211,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) { pos_T pos, tpos; @@ -2259,25 +2258,25 @@ int findsent(int dir, long count) 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)) { - if (vim_strchr((char_u *)".!?", c) != NULL) { - /* Only skip over a '.', '!' and '?' once. */ - if (found_dot) - break; - found_dot = TRUE; + while (c = gchar_pos(&pos), ascii_iswhite(c) + || vim_strchr((char_u *)".!?)]\"'", c) != NULL) { + tpos = pos; + if (decl(&tpos) == -1 || (LINEEMPTY(tpos.lnum) && dir == FORWARD)) { + break; } - if (decl(&pos) == -1) { + if (found_dot) { break; } - // when going forward: Stop in front of empty line - if (LINEEMPTY(pos.lnum) && dir == FORWARD) { - incl(&pos); - goto found; + if (vim_strchr((char_u *) ".!?", c) != NULL) { + found_dot = true; + } + if (vim_strchr((char_u *) ")]\"'", c) != NULL + && vim_strchr((char_u *) ".!?)]\"'", gchar_pos(&tpos)) == NULL) { + break; } + decl(&pos); } /* remember the line where the search started */ |