vim-patch:8.2.0999: moving to next sentence gets stuck on quote

Problem:    Moving to next sentence gets stuck on quote.
Solution:   When moving to the next sentence doesn't result in moving, advance
            a character and try again. (closes vim/vim#6291)
2f03e5a0a9
This commit is contained in:
Jan Edmund Lazo
2020-06-18 20:23:12 -04:00
parent 749429693d
commit b198225361
2 changed files with 25 additions and 3 deletions

View File

@@ -2326,9 +2326,9 @@ int findsent(Direction dir, long count)
func = decl; func = decl;
while (count--) { while (count--) {
/* const pos_T prev_pos = pos;
* if on an empty line, skip up to a non-empty line
*/ // if on an empty line, skip up to a non-empty line
if (gchar_pos(&pos) == NUL) { if (gchar_pos(&pos) == NUL) {
do { do {
if ((*func)(&pos) == -1) { if ((*func)(&pos) == -1) {
@@ -2411,6 +2411,17 @@ found:
while (!noskip && ((c = gchar_pos(&pos)) == ' ' || c == '\t')) while (!noskip && ((c = gchar_pos(&pos)) == ' ' || c == '\t'))
if (incl(&pos) == -1) if (incl(&pos) == -1)
break; break;
if (equalpos(prev_pos, pos)) {
// didn't actually move, advance one character and try again
if ((*func)(&pos) == -1) {
if (count) {
return FAIL;
}
break;
}
count++;
}
} }
setpcmark(); setpcmark();

View File

@@ -290,5 +290,16 @@ func! Test_sentence_with_cursor_on_delimiter()
normal! 17|yas normal! 17|yas
call assert_equal("A '([sentence.])' ", @") call assert_equal("A '([sentence.])' ", @")
" don't get stuck on a quote at the start of a sentence
%delete _
call setline(1, ['A sentence.', '"A sentence"?', 'A sentence!'])
normal gg))
call assert_equal(3, getcurpos()[1])
%delete _
call setline(1, ['A sentence.', "'A sentence'?", 'A sentence!'])
normal gg))
call assert_equal(3, getcurpos()[1])
%delete _ %delete _
endfunc endfunc