diff options
author | Aufar Gilbran <aufargilbran@gmail.com> | 2020-08-19 00:51:24 +0800 |
---|---|---|
committer | Aufar Gilbran <aufargilbran@gmail.com> | 2020-09-11 10:37:52 +0800 |
commit | e2dc2a6bd751f5614fb7f51a2bd1bc28c3bf4530 (patch) | |
tree | 9445c62f3d1ca75f4436261b129aab19d1c3caeb /src/nvim/ex_getln.c | |
parent | b59c293c25dce6387c939d536c4d7b0f98d83d9e (diff) | |
download | rneovim-e2dc2a6bd751f5614fb7f51a2bd1bc28c3bf4530.tar.gz rneovim-e2dc2a6bd751f5614fb7f51a2bd1bc28c3bf4530.tar.bz2 rneovim-e2dc2a6bd751f5614fb7f51a2bd1bc28c3bf4530.zip |
vim-patch:8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Problem: 'incsearch' for :/foo/s//<Esc> changes last search pattern.
Solution: Save the last search pattern earlier.
https://github.com/vim/vim/commit/198cb66d652d3d8ac16226dcc929a11b0b720151
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e89d835981..b3b81853a3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -422,13 +422,18 @@ static void may_do_incsearch_highlighting(int firstc, long count, char_u next_char; char_u use_last_pat; + // Parsing range may already set the last search pattern. + save_last_search_pattern(); + if (!do_incsearch_highlighting(firstc, s, &skiplen, &patlen)) { + restore_last_search_pattern(); finish_incsearch_highlighting(false, s, true); return; } // if there is a character waiting, search and redraw later if (char_avail()) { + restore_last_search_pattern(); s->incsearch_postponed = true; return; } @@ -442,7 +447,6 @@ static void may_do_incsearch_highlighting(int firstc, long count, curwin->w_cursor.lnum = search_first_line; curwin->w_cursor.col = 0; } - save_last_search_pattern(); int i; // Use the previous pattern for ":s//". @@ -556,8 +560,13 @@ static void may_do_incsearch_highlighting(int firstc, long count, static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s) { int skiplen, patlen; + + // Parsing range may already set the last search pattern. + save_last_search_pattern(); + // Add a character from under the cursor for 'incsearch' if (!do_incsearch_highlighting(firstc, s, &skiplen, &patlen)) { + restore_last_search_pattern(); return FAIL; } @@ -1431,10 +1440,16 @@ static int may_do_command_line_next_incsearch(int firstc, long count, bool next_match) { int skiplen, patlen; + + // Parsing range may already set the last search pattern. + save_last_search_pattern(); + if (!do_incsearch_highlighting(firstc, s, &skiplen, &patlen)) { + restore_last_search_pattern(); return OK; } if (patlen == 0 && ccline.cmdbuff[skiplen] == NUL) { + restore_last_search_pattern(); return FAIL; } @@ -1455,8 +1470,6 @@ static int may_do_command_line_next_incsearch(int firstc, long count, pat = ccline.cmdbuff + skiplen; } - save_last_search_pattern(); - if (next_match) { t = s->match_end; if (lt(s->match_start, s->match_end)) { |