diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-16 20:46:28 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-16 20:55:46 -0400 |
commit | 0b60372792f88cc6e87d0b985834251662ff5940 (patch) | |
tree | 529b0ee8864320932e05db7f6133ebd57d1f7901 | |
parent | 91352b36b70ef20a4d1b94c4160129bf5f0d6b60 (diff) | |
download | rneovim-0b60372792f88cc6e87d0b985834251662ff5940.tar.gz rneovim-0b60372792f88cc6e87d0b985834251662ff5940.tar.bz2 rneovim-0b60372792f88cc6e87d0b985834251662ff5940.zip |
vim-patch:8.0.1417: test doesn't search for a sentence
Problem: Test doesn't search for a sentence. Still fails when searching for
start of sentence. (Dominique Pelle)
Solution: Add paren. Check for MAXCOL in dec().
https://github.com/vim/vim/commit/1bd999f982e783219a06e6c8f219df1d53ac7e77
-rw-r--r-- | src/nvim/memline.c | 18 | ||||
-rw-r--r-- | src/nvim/testdir/test_search.vim | 4 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index a787e2f104..e84b8d623d 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -4032,20 +4032,32 @@ int incl(pos_T *lp) int dec(pos_T *lp) { lp->coladd = 0; - if (lp->col > 0) { // still within line + if (lp->col == MAXCOL) { + // past end of line + char_u *p = ml_get(lp->lnum); + lp->col = (colnr_T)STRLEN(p); + lp->col -= utf_head_off(p, p + lp->col); + return 0; + } + + if (lp->col > 0) { + // still within line lp->col--; char_u *p = ml_get(lp->lnum); lp->col -= utf_head_off(p, p + lp->col); return 0; } - if (lp->lnum > 1) { // there is a prior line + if (lp->lnum > 1) { + // there is a prior line lp->lnum--; char_u *p = ml_get(lp->lnum); lp->col = (colnr_T)STRLEN(p); lp->col -= utf_head_off(p, p + lp->col); return 1; } - return -1; // at start of file + + // at start of file + return -1; } /// Same as dec(), but skip NUL at the end of non-empty lines. diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 6780fb0b44..ecd840d40c 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -484,6 +484,8 @@ endfunc func Test_search_sentence() new " this used to cause a crash - call assert_fails("/\\%'", 'E486') + call assert_fails("/\\%')", 'E486') call assert_fails("/", 'E486') + /\%'( + / endfunc |