]> granicus.if.org Git - vim/commitdiff
patch 8.0.1304: CTRL-G/CTRL-T don't work with incsearch and empty pattern v8.0.1304
authorBram Moolenaar <Bram@vim.org>
Thu, 16 Nov 2017 21:20:39 +0000 (22:20 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 16 Nov 2017 21:20:39 +0000 (22:20 +0100)
Problem:    CTRL-G/CTRL-T don't work with incsearch and empty pattern.
Solution:   Use the last search pattern. (Christian Brabandt, closes #2292)

src/ex_getln.c
src/proto/search.pro
src/search.c
src/testdir/test_search.vim
src/version.c

index 0270477283c8f27c46d3b231052d3a83e6ae4169..7c0db89a87d7a6b26cd90235978df8fe98aa1deb 100644 (file)
@@ -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)
index 41c200612f0443c3687b6e3765f22b034c08a913..4e63bf31a0487fa915098d80b9e0f7897bb8d221 100644 (file)
@@ -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);
index fc689db2df60804900adbb7b41ce08b3f998dbeb..8bb5f3d97aabccd3eab3ae15d913fb5adc5b928f 100644 (file)
@@ -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
 
 /*
index 2a660c61b848be7f04d5dd7e73d4efffbabf92db..d13e65458e3747ca2a42f012733a4a6e89af9492 100644 (file)
@@ -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!
index 2789f2bde4918d3d0ccda1bc4ef9e648269d9134..1dd52da3510f3688fd6a5f24b50aa77c1daaf848 100644 (file)
@@ -766,6 +766,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1304,
 /**/
     1303,
 /**/