To: vim_dev@googlegroups.com Subject: Patch 8.0.1304 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.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) Files: src/ex_getln.c, src/proto/search.pro, src/search.c, src/testdir/test_search.vim *** ../vim-8.0.1303/src/ex_getln.c 2017-11-02 19:08:39.741514601 +0100 --- src/ex_getln.c 2017-11-16 22:18:45.622301697 +0100 *************** *** 220,226 **** pos_T match_end; # ifdef FEAT_DIFF int old_topfill; ! int init_topfill = curwin->w_topfill; # endif linenr_T old_botline; linenr_T init_botline = curwin->w_botline; --- 220,226 ---- pos_T match_end; # ifdef FEAT_DIFF int old_topfill; ! int init_topfill = curwin->w_topfill; # endif linenr_T old_botline; linenr_T init_botline = curwin->w_botline; *************** *** 1715,1725 **** --- 1715,1731 ---- 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,1745 **** ++emsg_off; i = searchit(curwin, curbuf, &t, c == Ctrl_G ? FORWARD : BACKWARD, ! ccline.cmdbuff, count, search_flags, RE_SEARCH, 0, NULL, NULL); --emsg_off; if (i) --- 1745,1751 ---- ++emsg_off; i = searchit(curwin, curbuf, &t, c == Ctrl_G ? FORWARD : BACKWARD, ! pat, count, search_flags, RE_SEARCH, 0, NULL, NULL); --emsg_off; if (i) *** ../vim-8.0.1303/src/proto/search.pro 2017-10-29 16:39:36.262313855 +0100 --- src/proto/search.pro 2017-11-16 22:15:53.776952095 +0100 *************** *** 7,12 **** --- 7,13 ---- 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); *** ../vim-8.0.1303/src/search.c 2017-11-12 15:36:34.025935624 +0100 --- src/search.c 2017-11-16 22:15:53.780952032 +0100 *************** *** 393,398 **** --- 393,404 ---- last_idx = saved_last_idx; SET_NO_HLSEARCH(saved_no_hlsearch); } + + char_u * + last_search_pattern(void) + { + return spats[RE_SEARCH].pat; + } #endif /* *** ../vim-8.0.1303/src/testdir/test_search.vim 2017-11-05 20:59:12.528905134 +0100 --- src/testdir/test_search.vim 2017-11-16 22:15:53.780952032 +0100 *************** *** 461,466 **** --- 461,475 ---- " moves to next match of previous search pattern, just like / call feedkeys("/\\", '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\\", 'tx') + call assert_equal('1 bbvimb', getline('.')) + call assert_equal(4, col('.')) + set noincsearch call test_override("char_avail", 0) bw! *** ../vim-8.0.1303/src/version.c 2017-11-16 22:07:09.221057409 +0100 --- src/version.c 2017-11-16 22:17:44.455244909 +0100 *************** *** 768,769 **** --- 768,771 ---- { /* Add new patch number below this line */ + /**/ + 1304, /**/ -- Q: What's a light-year? A: One-third less calories than a regular year. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///