aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bürgin <676c7473@gmail.com>2015-03-27 09:34:54 +0100
committerJustin M. Keyes <justinkz@gmail.com>2015-04-05 21:35:17 -0400
commit7a5a85d2c4711dce3d0850af93d510eed46fe118 (patch)
treee3c34a995d8a505fb19ef7ef305e1bf3c132e099
parent23425a3a6ec3c86a75b411bd9683d11cfd80ae17 (diff)
downloadrneovim-7a5a85d2c4711dce3d0850af93d510eed46fe118.tar.gz
rneovim-7a5a85d2c4711dce3d0850af93d510eed46fe118.tar.bz2
rneovim-7a5a85d2c4711dce3d0850af93d510eed46fe118.zip
vim-patch:7.4.636 #2267
Problem: A search with end offset gets stuck at end of file. (Gary Johnson) Solution: When a search doesn't move the cursor repeat it with a higher count. (Christian Brabandt) https://github.com/vim/vim/releases/tag/v7-4-636
-rw-r--r--src/nvim/normal.c21
-rw-r--r--src/nvim/testdir/test44.in6
-rw-r--r--src/nvim/testdir/test44.ok2
-rw-r--r--src/nvim/version.c2
4 files changed, 25 insertions, 6 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index e26f5a3d77..c210c8fe8f 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -4361,7 +4361,7 @@ static void nv_ident(cmdarg_T *cap)
/* put pattern in search history */
init_history();
add_to_history(HIST_SEARCH, buf, true, NUL);
- normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);
+ (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);
} else
do_cmdline_cmd(buf);
@@ -4785,7 +4785,7 @@ static void nv_search(cmdarg_T *cap)
return;
}
- normal_search(cap, cap->cmdchar, cap->searchbuf,
+ (void)normal_search(cap, cap->cmdchar, cap->searchbuf,
(cap->arg ? 0 : SEARCH_MARK));
}
@@ -4795,15 +4795,25 @@ static void nv_search(cmdarg_T *cap)
*/
static void nv_next(cmdarg_T *cap)
{
- normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
+ pos_T old = curwin->w_cursor;
+ int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
+
+ if (i == 1 && equalpos(old, curwin->w_cursor)) {
+ // Avoid getting stuck on the current cursor position, which can happen when
+ // an offset is given and the cursor is on the last char in the buffer:
+ // Repeat with count + 1.
+ cap->count1 += 1;
+ (void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
+ cap->count1 -= 1;
+ }
}
/*
* Search for "pat" in direction "dir" ('/' or '?', 0 for repeat).
* Uses only cap->count1 and cap->oap from "cap".
+ * Return 0 for failure, 1 for found, 2 for found and line offset added.
*/
-static void
-normal_search (
+static int normal_search(
cmdarg_T *cap,
int dir,
char_u *pat,
@@ -4832,6 +4842,7 @@ normal_search (
/* "/$" will put the cursor after the end of the line, may need to
* correct that here */
check_cursor();
+ return i;
}
/*
diff --git a/src/nvim/testdir/test44.in b/src/nvim/testdir/test44.in
index 65b08b08b8..7b1a13488f 100644
--- a/src/nvim/testdir/test44.in
+++ b/src/nvim/testdir/test44.in
@@ -42,6 +42,12 @@ G:put =matchstr(\"אבגד\", \".\", 0, 2) " ב
:put =matchstr(\"אבגד\", \"..\", 0, 2) " בג
:put =matchstr(\"אבגד\", \".\", 0, 0) " א
:put =matchstr(\"אבגד\", \".\", 4, -1) " ג
+:new
+:$put =['dog(a', 'cat(']
+/(/e+
+"ayn:bd!
+:$put =''
+G"ap
:w!
:qa!
ENDTEST
diff --git a/src/nvim/testdir/test44.ok b/src/nvim/testdir/test44.ok
index 0bd0b8ab73..d9a1206cc2 100644
--- a/src/nvim/testdir/test44.ok
+++ b/src/nvim/testdir/test44.ok
@@ -22,3 +22,5 @@ k œ̄ṣ́m̥̄ᾱ̆́
בג
א
ג
+a
+cat(
diff --git a/src/nvim/version.c b/src/nvim/version.c
index bbe5500d3d..1a5eb523fa 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -104,7 +104,7 @@ static int included_patches[] = {
//639,
//638,
637,
- //636,
+ 636,
//635,
//634,
//633,