summaryrefslogtreecommitdiff
path: root/src/ex_getln.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-09-06 21:44:17 +0200
committerBram Moolenaar <Bram@vim.org>2018-09-06 21:44:17 +0200
commit198cb66d652d3d8ac16226dcc929a11b0b720151 (patch)
tree23ab498998bff1956e3d4e658918843dc7566db0 /src/ex_getln.c
parent0b1468884a2a1c5d3442cbb7119330e307f0aa3d (diff)
downloadvim-git-198cb66d652d3d8ac16226dcc929a11b0b720151.tar.gz
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search patternv8.1.0351
Problem: 'incsearch' for :/foo/s//<Esc> changes last search pattern. Solution: Save the last search pattern earlier.
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r--src/ex_getln.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index c316e192a..80f210a5b 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -271,6 +271,7 @@ set_search_match(pos_T *t)
/*
* Return TRUE when 'incsearch' highlighting is to be done.
* Sets search_first_line and search_last_line to the address range.
+ * May change the last search pattern.
*/
static int
do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
@@ -470,8 +471,12 @@ may_do_incsearch_highlighting(
int next_char;
int use_last_pat;
+ // Parsing range may already set the last search pattern.
+ save_last_search_pattern();
+
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
{
+ restore_last_search_pattern();
finish_incsearch_highlighting(FALSE, is_state, TRUE);
return;
}
@@ -479,6 +484,7 @@ may_do_incsearch_highlighting(
// If there is a character waiting, search and redraw later.
if (char_avail())
{
+ restore_last_search_pattern();
is_state->incsearch_postponed = TRUE;
return;
}
@@ -493,7 +499,6 @@ may_do_incsearch_highlighting(
curwin->w_cursor.lnum = search_first_line;
curwin->w_cursor.col = 0;
}
- save_last_search_pattern();
// Use the previous pattern for ":s//".
next_char = ccline.cmdbuff[skiplen + patlen];
@@ -627,10 +632,19 @@ may_adjust_incsearch_highlighting(
int i;
int save;
+ // Parsing range may already set the last search pattern.
+ save_last_search_pattern();
+
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
+ {
+ restore_last_search_pattern();
return OK;
+ }
if (patlen == 0 && ccline.cmdbuff[skiplen] == NUL)
+ {
+ restore_last_search_pattern();
return FAIL;
+ }
if (firstc == ccline.cmdbuff[skiplen])
{
@@ -641,7 +655,6 @@ may_adjust_incsearch_highlighting(
else
pat = ccline.cmdbuff + skiplen;
- save_last_search_pattern();
cursor_off();
out_flush();
if (c == Ctrl_G)
@@ -721,8 +734,14 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
{
int skiplen, patlen;
+ // Parsing range may already set the last search pattern.
+ save_last_search_pattern();
+
if (!do_incsearch_highlighting(firstc, is_state, &skiplen, &patlen))
+ {
+ restore_last_search_pattern();
return FAIL;
+ }
// Add a character from under the cursor for 'incsearch'.
if (is_state->did_incsearch)