diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-11-16 22:20:39 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-11-16 22:20:39 +0100 |
commit | d0480097177369a6ed91d47aba189ae647afcd68 (patch) | |
tree | 843535035064603b175733322adad326163a735c | |
parent | 9c6ce0e62297294b41344e684429a91853bc2268 (diff) | |
download | vim-git-d0480097177369a6ed91d47aba189ae647afcd68.tar.gz |
patch 8.0.1304: CTRL-G/CTRL-T don't work with incsearch and empty patternv8.0.1304
Problem: CTRL-G/CTRL-T don't work with incsearch and empty pattern.
Solution: Use the last search pattern. (Christian Brabandt, closes #2292)
-rw-r--r-- | src/ex_getln.c | 10 | ||||
-rw-r--r-- | src/proto/search.pro | 1 | ||||
-rw-r--r-- | src/search.c | 6 | ||||
-rw-r--r-- | src/testdir/test_search.vim | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 26 insertions, 2 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index 027047728..7c0db89a8 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -220,7 +220,7 @@ getcmdline( pos_T match_end; # ifdef FEAT_DIFF int old_topfill; - int init_topfill = curwin->w_topfill; + int init_topfill = curwin->w_topfill; # endif linenr_T old_botline; linenr_T init_botline = curwin->w_botline; @@ -1715,11 +1715,17 @@ getcmdline( if (p_is && !cmd_silent && (firstc == '/' || firstc == '?')) { pos_T t; + char_u *pat; int search_flags = SEARCH_NOOF; if (ccline.cmdlen == 0) goto cmdline_not_changed; + if (firstc == ccline.cmdbuff[0]) + pat = last_search_pattern(); + else + pat = ccline.cmdbuff; + save_last_search_pattern(); cursor_off(); out_flush(); @@ -1739,7 +1745,7 @@ getcmdline( ++emsg_off; i = searchit(curwin, curbuf, &t, c == Ctrl_G ? FORWARD : BACKWARD, - ccline.cmdbuff, count, search_flags, + pat, count, search_flags, RE_SEARCH, 0, NULL, NULL); --emsg_off; if (i) diff --git a/src/proto/search.pro b/src/proto/search.pro index 41c200612..4e63bf31a 100644 --- a/src/proto/search.pro +++ b/src/proto/search.pro @@ -7,6 +7,7 @@ void save_search_patterns(void); void restore_search_patterns(void); void save_last_search_pattern(void); void restore_last_search_pattern(void); +char_u *last_search_pattern(void); void free_search_patterns(void); int ignorecase(char_u *pat); int ignorecase_opt(char_u *pat, int ic_in, int scs); diff --git a/src/search.c b/src/search.c index fc689db2d..8bb5f3d97 100644 --- a/src/search.c +++ b/src/search.c @@ -393,6 +393,12 @@ restore_last_search_pattern(void) last_idx = saved_last_idx; SET_NO_HLSEARCH(saved_no_hlsearch); } + + char_u * +last_search_pattern(void) +{ + return spats[RE_SEARCH].pat; +} #endif /* diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim index 2a660c61b..d13e65458 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -461,6 +461,15 @@ func Test_search_cmdline7() " moves to next match of previous search pattern, just like /<cr> call feedkeys("/\<c-t>\<cr>", 'tx') call assert_equal([0,1,7,0], getpos('.')) + + " using an offset uses the last search pattern + call cursor(1, 1) + call setline(1, ['1 bbvimb', ' 2 bbvimb']) + let @/ = 'b' + call feedkeys("//e\<c-g>\<cr>", 'tx') + call assert_equal('1 bbvimb', getline('.')) + call assert_equal(4, col('.')) + set noincsearch call test_override("char_avail", 0) bw! diff --git a/src/version.c b/src/version.c index 2789f2bde..1dd52da35 100644 --- a/src/version.c +++ b/src/version.c @@ -767,6 +767,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1304, +/**/ 1303, /**/ 1302, |