aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAufar Gilbran <aufargilbran@gmail.com>2020-08-19 00:54:50 +0800
committerAufar Gilbran <aufargilbran@gmail.com>2020-09-11 10:37:52 +0800
commit112092fa1598fbfa9dae723da5e52d2dec8da2f0 (patch)
treee33c861f6d27e660b25696e822596563f6e77b63 /src
parentb0042cafc072c92e0db07cecb6ff03a9fc1df78e (diff)
downloadrneovim-112092fa1598fbfa9dae723da5e52d2dec8da2f0.tar.gz
rneovim-112092fa1598fbfa9dae723da5e52d2dec8da2f0.tar.bz2
rneovim-112092fa1598fbfa9dae723da5e52d2dec8da2f0.zip
vim-patch:8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Problem: Error while typing :/foo/s// with 'incsearch' enabled. Solution: Do not give search errors when highlighting matches. https://github.com/vim/vim/commit/50eb16c3b23235b21ce4494673a7741a9a196176
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c30
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/testdir/test_search.vim4
3 files changed, 22 insertions, 14 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 78d46ad5ee..dfebd13868 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1371,7 +1371,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
ea.cmd = cmd;
- if (parse_cmd_address(&ea, &errormsg) == FAIL) {
+ if (parse_cmd_address(&ea, &errormsg, false) == FAIL) {
goto doend;
}
@@ -2229,7 +2229,7 @@ int parse_command_modifiers(exarg_T *eap, char_u **errormsg, bool skip_only)
case 't': if (checkforcmd(&p, "tab", 3)) {
long tabnr = get_address(
- eap, &eap->cmd, ADDR_TABS, eap->skip, false, 1);
+ eap, &eap->cmd, ADDR_TABS, eap->skip, skip_only, false, 1);
if (tabnr == MAXLNUM) {
cmdmod.tab = tabpage_index(curtab) + 1;
@@ -2301,9 +2301,9 @@ static void free_cmdmod(void)
// Parse the address range, if any, in "eap".
-// May set the last search pattern.
+// May set the last search pattern, unless "silent" is true.
// Return FAIL and set "errormsg" or return OK.
-int parse_cmd_address(exarg_T *eap, char_u **errormsg)
+int parse_cmd_address(exarg_T *eap, char_u **errormsg, bool silent)
FUNC_ATTR_NONNULL_ALL
{
int address_count = 1;
@@ -2341,7 +2341,7 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg)
break;
}
eap->cmd = skipwhite(eap->cmd);
- lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip,
+ lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,
eap->addr_count == 0, address_count++);
if (eap->cmd == NULL) { // error detected
return FAIL;
@@ -3695,6 +3695,7 @@ static linenr_T get_address(exarg_T *eap,
char_u **ptr,
int addr_type, // flag: one of ADDR_LINES, ...
int skip, // only skip the address, don't use it
+ bool silent, // no errors or side effects
int to_other_file, // flag: may jump to other file
int address_count) // 1 for first, >1 after comma
{
@@ -3826,13 +3827,15 @@ static linenr_T get_address(exarg_T *eap,
if (*cmd == c)
++cmd;
} else {
- pos = curwin->w_cursor; /* save curwin->w_cursor */
- /*
- * When '/' or '?' follows another address, start
- * from there.
- */
- if (lnum != MAXLNUM)
+ int flags;
+
+ pos = curwin->w_cursor; // save curwin->w_cursor
+
+ // When '/' or '?' follows another address, start from
+ // there.
+ if (lnum != MAXLNUM) {
curwin->w_cursor.lnum = lnum;
+ }
// Start a forward search at the end of the line (unless
// before the first line).
@@ -3846,7 +3849,8 @@ static linenr_T get_address(exarg_T *eap,
curwin->w_cursor.col = 0;
}
searchcmdlen = 0;
- if (!do_search(NULL, c, cmd, 1L, SEARCH_HIS | SEARCH_MSG, NULL)) {
+ flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;
+ if (!do_search(NULL, c, cmd, 1L, flags, NULL)) {
curwin->w_cursor = pos;
cmd = NULL;
goto error;
@@ -7751,7 +7755,7 @@ static void ex_put(exarg_T *eap)
*/
static void ex_copymove(exarg_T *eap)
{
- long n = get_address(eap, &eap->arg, eap->addr_type, false, false, 1);
+ long n = get_address(eap, &eap->arg, eap->addr_type, false, false, false, 1);
if (eap->arg == NULL) { // error detected
eap->nextcmd = NULL;
return;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 7cfee9df82..960b7cf03f 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -391,7 +391,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
// parse the address range
save_cursor = curwin->w_cursor;
curwin->w_cursor = s->search_start;
- parse_cmd_address(&ea, &dummy);
+ parse_cmd_address(&ea, &dummy, true);
if (ea.addr_count > 0) {
// Allow for reverse match.
if (ea.line2 < ea.line1) {
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 8741def3bf..ec4c15cd11 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -796,6 +796,10 @@ func Test_keep_last_search_pattern()
call feedkeys(":/foo/s//\<Esc>", 'ntx')
call assert_equal('bar', @/)
+ " no error message if pattern not found
+ call feedkeys(":/xyz/s//\<Esc>", 'ntx')
+ call assert_equal('bar', @/)
+
bwipe!
call test_override("ALL", 0)
set noincsearch