summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-27 16:26:56 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-27 16:26:56 +0200
commit1195669f9e434fa9ab8b57ee9470bf951e4990b8 (patch)
tree54a1a54c5bb4f6a37e116b27a5eab35c77431a48
parent44ca54aeb9a0eca41aea203786e33d82e69d0615 (diff)
patch 7.4.2268v7.4.2268
Problem: Using CTRL-N and CTRL-P for incsearch shadows completion keys. Solution: Use CTRL-T and CTRL-G instead.
-rw-r--r--runtime/doc/cmdline.txt23
-rw-r--r--src/ex_getln.c143
-rw-r--r--src/testdir/test_search.vim80
-rw-r--r--src/version.c2
4 files changed, 129 insertions, 119 deletions
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 7fe2a3442e..95bd3554ad 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -1,4 +1,4 @@
-*cmdline.txt* For Vim version 7.4. Last change: 2015 Dec 17
+*cmdline.txt* For Vim version 7.4. Last change: 2016 Aug 27
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -409,19 +409,11 @@ CTRL-D List names that match the pattern in front of the cursor.
*c_CTRL-N*
CTRL-N After using 'wildchar' which got multiple matches, go to next
match. Otherwise recall more recent command-line from history.
- */_CTRL-N*
- When 'incsearch' is set, entering a search pattern for "/" or
- "?" and the current match is displayed then CTRL-N will move
- to the next match (does not take |search-offset| into account)
<S-Tab> *c_CTRL-P* *c_<S-Tab>*
CTRL-P After using 'wildchar' which got multiple matches, go to
previous match. Otherwise recall older command-line from
history. <S-Tab> only works with the GUI, on the Amiga and
with MS-DOS.
- */_CTRL-P*
- When 'incsearch' is set, entering a search pattern for "/" or
- "?" and the current match is displayed then CTRL-P will move
- to the previous match (does not take |search-offset| into account).
*c_CTRL-A*
CTRL-A All names that match the pattern in front of the cursor are
inserted.
@@ -438,6 +430,19 @@ CTRL-L A match is done on the pattern in front of the cursor. If
'ignorecase' and 'smartcase' are set and the command line has
no uppercase characters, the added character is converted to
lowercase.
+ *c_CTRL-G* */_CTRL-G*
+CTRL-G When 'incsearch' is set, entering a search pattern for "/" or
+ "?" and the current match is displayed then CTRL-G will move
+ to the next match (does not take |search-offset| into account)
+ Use CTRL-T to move to the previous match. Hint: on a regular
+ keyboard T is above G.
+ *c_CTRL-T* */_CTRL-T*
+CTRL-T When 'incsearch' is set, entering a search pattern for "/" or
+ "?" and the current match is displayed then CTRL-T will move
+ to the previous match (does not take |search-offset| into
+ account).
+ Use CTRL-G to move to the next match. Hint: on a regular
+ keyboard T is above G.
The 'wildchar' option defaults to <Tab> (CTRL-E when in Vi compatible mode; in
a previous version <Esc> was used). In the pattern standard wildcards '*' and
diff --git a/src/ex_getln.c b/src/ex_getln.c
index f6e5097f62..3ac5fd6f2e 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1503,82 +1503,14 @@ getcmdline(
case Ctrl_N: /* next match */
case Ctrl_P: /* previous match */
-#ifdef FEAT_SEARCH_EXTRA
- if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
- {
- pos_T t;
- int search_flags = SEARCH_KEEP + SEARCH_NOOF
- + SEARCH_PEEK;
-
- if (char_avail())
- continue;
- cursor_off();
- out_flush();
- if (c == Ctrl_N)
- {
- t = match_end;
- search_flags += SEARCH_COL;
- }
- else
- t = match_start;
- ++emsg_off;
- i = searchit(curwin, curbuf, &t,
- c == Ctrl_N ? FORWARD : BACKWARD,
- ccline.cmdbuff, count, search_flags,
- RE_SEARCH, 0, NULL);
- --emsg_off;
- if (i)
- {
- old_cursor = match_start;
- match_end = t;
- match_start = t;
- if (c == Ctrl_P && firstc == '/')
- {
- /* move just before the current match, so that
- * when nv_search finishes the cursor will be
- * put back on the match */
- old_cursor = t;
- (void)decl(&old_cursor);
- }
- if (lt(t, old_cursor) && c == Ctrl_N)
- {
- /* wrap around */
- old_cursor = t;
- if (firstc == '?')
- (void)incl(&old_cursor);
- else
- (void)decl(&old_cursor);
- }
-
- set_search_match(&match_end);
- curwin->w_cursor = match_start;
- changed_cline_bef_curs();
- update_topline();
- validate_cursor();
- highlight_match = TRUE;
- old_curswant = curwin->w_curswant;
- old_leftcol = curwin->w_leftcol;
- old_topline = curwin->w_topline;
-# ifdef FEAT_DIFF
- old_topfill = curwin->w_topfill;
-# endif
- old_botline = curwin->w_botline;
- update_screen(NOT_VALID);
- redrawcmdline();
- }
- else
- vim_beep(BO_ERROR);
- goto cmdline_not_changed;
- }
- else
-#endif
if (xpc.xp_numfiles > 0)
{
if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT,
0, firstc != '@') == FAIL)
break;
- goto cmdline_changed;
+ goto cmdline_not_changed;
}
+ /* FALLTHROUGH */
#ifdef FEAT_CMDHIST
case K_UP:
@@ -1722,6 +1654,77 @@ getcmdline(
goto cmdline_changed;
}
beep_flush();
+#endif
+ goto cmdline_not_changed;
+
+ case Ctrl_G: /* next match */
+ case Ctrl_T: /* previous match */
+#ifdef FEAT_SEARCH_EXTRA
+ if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
+ {
+ pos_T t;
+ int search_flags = SEARCH_KEEP + SEARCH_NOOF
+ + SEARCH_PEEK;
+
+ if (char_avail())
+ continue;
+ cursor_off();
+ out_flush();
+ if (c == Ctrl_G)
+ {
+ t = match_end;
+ search_flags += SEARCH_COL;
+ }
+ else
+ t = match_start;
+ ++emsg_off;
+ i = searchit(curwin, curbuf, &t,
+ c == Ctrl_G ? FORWARD : BACKWARD,
+ ccline.cmdbuff, count, search_flags,
+ RE_SEARCH, 0, NULL);
+ --emsg_off;
+ if (i)
+ {
+ old_cursor = match_start;
+ match_end = t;
+ match_start = t;
+ if (c == Ctrl_T && firstc == '/')
+ {
+ /* move just before the current match, so that
+ * when nv_search finishes the cursor will be
+ * put back on the match */
+ old_cursor = t;
+ (void)decl(&old_cursor);
+ }
+ if (lt(t, old_cursor) && c == Ctrl_G)
+ {
+ /* wrap around */
+ old_cursor = t;
+ if (firstc == '?')
+ (void)incl(&old_cursor);
+ else
+ (void)decl(&old_cursor);
+ }
+
+ set_search_match(&match_end);
+ curwin->w_cursor = match_start;
+ changed_cline_bef_curs();
+ update_topline();
+ validate_cursor();
+ highlight_match = TRUE;
+ old_curswant = curwin->w_curswant;
+ old_leftcol = curwin->w_leftcol;
+ old_topline = curwin->w_topline;
+# ifdef FEAT_DIFF
+ old_topfill = curwin->w_topfill;
+# endif
+ old_botline = curwin->w_botline;
+ update_screen(NOT_VALID);
+ redrawcmdline();
+ }
+ else
+ vim_beep(BO_ERROR);
+ }
goto cmdline_not_changed;
#endif
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 4f1cfcc8e4..6e5146079a 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -16,11 +16,11 @@ func Test_search_cmdline()
call feedkeys("/foobar\<cr>", 'tx')
call feedkeys("/the\<cr>",'tx')
call assert_equal('the', @/)
- call feedkeys("/thes\<c-p>\<c-p>\<cr>",'tx')
+ call feedkeys("/thes\<C-P>\<C-P>\<cr>",'tx')
call assert_equal('foobar', @/)
" Test 2
- " Ctrl-N goes from one match to the next
+ " Ctrl-G goes from one match to the next
" until the end of the buffer
set incsearch nowrapscan
:1
@@ -29,39 +29,39 @@ func Test_search_cmdline()
call assert_equal(' 2 these', getline('.'))
:1
" second match
- call feedkeys("/the\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<cr>", 'tx')
call assert_equal(' 3 the', getline('.'))
:1
" third match
- call feedkeys("/the".repeat("\<c-n>", 2)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 2)."\<cr>", 'tx')
call assert_equal(' 4 their', getline('.'))
:1
" fourth match
- call feedkeys("/the".repeat("\<c-n>", 3)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 3)."\<cr>", 'tx')
call assert_equal(' 5 there', getline('.'))
:1
" fifth match
- call feedkeys("/the".repeat("\<c-n>", 4)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 4)."\<cr>", 'tx')
call assert_equal(' 6 their', getline('.'))
:1
" sixth match
- call feedkeys("/the".repeat("\<c-n>", 5)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 5)."\<cr>", 'tx')
call assert_equal(' 7 the', getline('.'))
:1
" seventh match
- call feedkeys("/the".repeat("\<c-n>", 6)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 6)."\<cr>", 'tx')
call assert_equal(' 8 them', getline('.'))
:1
" eigth match
- call feedkeys("/the".repeat("\<c-n>", 7)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 7)."\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
:1
" no further match
- call feedkeys("/the".repeat("\<c-n>", 8)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 8)."\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
" Test 3
- " Ctrl-N goes from one match to the next
+ " Ctrl-G goes from one match to the next
" and continues back at the top
set incsearch wrapscan
:1
@@ -70,39 +70,39 @@ func Test_search_cmdline()
call assert_equal(' 2 these', getline('.'))
:1
" second match
- call feedkeys("/the\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<cr>", 'tx')
call assert_equal(' 3 the', getline('.'))
:1
" third match
- call feedkeys("/the".repeat("\<c-n>", 2)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 2)."\<cr>", 'tx')
call assert_equal(' 4 their', getline('.'))
:1
" fourth match
- call feedkeys("/the".repeat("\<c-n>", 3)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 3)."\<cr>", 'tx')
call assert_equal(' 5 there', getline('.'))
:1
" fifth match
- call feedkeys("/the".repeat("\<c-n>", 4)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 4)."\<cr>", 'tx')
call assert_equal(' 6 their', getline('.'))
:1
" sixth match
- call feedkeys("/the".repeat("\<c-n>", 5)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 5)."\<cr>", 'tx')
call assert_equal(' 7 the', getline('.'))
:1
" seventh match
- call feedkeys("/the".repeat("\<c-n>", 6)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 6)."\<cr>", 'tx')
call assert_equal(' 8 them', getline('.'))
:1
" eigth match
- call feedkeys("/the".repeat("\<c-n>", 7)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 7)."\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
:1
" back at first match
- call feedkeys("/the".repeat("\<c-n>", 8)."\<cr>", 'tx')
+ call feedkeys("/the".repeat("\<C-G>", 8)."\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
" Test 4
- " CTRL-P goes to the previous match
+ " CTRL-T goes to the previous match
set incsearch nowrapscan
$
" first match
@@ -110,23 +110,23 @@ func Test_search_cmdline()
call assert_equal(' 9 these', getline('.'))
$
" first match
- call feedkeys("?the\<c-n>\<cr>", 'tx')
+ call feedkeys("?the\<C-G>\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
$
" second match
- call feedkeys("?the".repeat("\<c-p>", 1)."\<cr>", 'tx')
+ call feedkeys("?the".repeat("\<C-T>", 1)."\<cr>", 'tx')
call assert_equal(' 8 them', getline('.'))
$
" last match
- call feedkeys("?the".repeat("\<c-p>", 7)."\<cr>", 'tx')
+ call feedkeys("?the".repeat("\<C-T>", 7)."\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
$
" last match
- call feedkeys("?the".repeat("\<c-p>", 8)."\<cr>", 'tx')
+ call feedkeys("?the".repeat("\<C-T>", 8)."\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
" Test 5
- " CTRL-P goes to the previous match
+ " CTRL-T goes to the previous match
set incsearch wrapscan
$
" first match
@@ -134,19 +134,19 @@ func Test_search_cmdline()
call assert_equal(' 9 these', getline('.'))
$
" first match at the top
- call feedkeys("?the\<c-n>\<cr>", 'tx')
+ call feedkeys("?the\<C-G>\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
$
" second match
- call feedkeys("?the".repeat("\<c-p>", 1)."\<cr>", 'tx')
+ call feedkeys("?the".repeat("\<C-T>", 1)."\<cr>", 'tx')
call assert_equal(' 8 them', getline('.'))
$
" last match
- call feedkeys("?the".repeat("\<c-p>", 7)."\<cr>", 'tx')
+ call feedkeys("?the".repeat("\<C-T>", 7)."\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
$
" back at the bottom of the buffer
- call feedkeys("?the".repeat("\<c-p>", 8)."\<cr>", 'tx')
+ call feedkeys("?the".repeat("\<C-T>", 8)."\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
" Test 6
@@ -158,16 +158,16 @@ func Test_search_cmdline()
call assert_equal(' 2 these', getline('.'))
1
" go to next match of 'thes'
- call feedkeys("/the\<c-l>\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<c-l>\<C-G>\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
1
" wrap around
- call feedkeys("/the\<c-l>\<c-n>\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<c-l>\<C-G>\<C-G>\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
1
" wrap around
set nowrapscan
- call feedkeys("/the\<c-l>\<c-n>\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<c-l>\<C-G>\<C-G>\<cr>", 'tx')
call assert_equal(' 9 these', getline('.'))
" Test 7
@@ -183,7 +183,7 @@ func Test_search_cmdline()
call assert_equal(' 9 these', getline('.'))
1
" delete one char, add another, go to previous match, add one char
- call feedkeys("/thei\<bs>s\<bs>\<c-p>\<c-l>\<cr>", 'tx')
+ call feedkeys("/thei\<bs>s\<bs>\<C-T>\<c-l>\<cr>", 'tx')
call assert_equal(' 8 them', getline('.'))
1
" delete all chars, start from the beginning again
@@ -205,7 +205,7 @@ func Test_search_cmdline2()
new
call setline(1, [' 1', ' 2 these', ' 3 the theother'])
" Test 1
- " Ctrl-P goes correctly back and forth
+ " Ctrl-T goes correctly back and forth
set incsearch
1
" first match
@@ -213,27 +213,27 @@ func Test_search_cmdline2()
call assert_equal(' 2 these', getline('.'))
1
" go to next match (on next line)
- call feedkeys("/the\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<cr>", 'tx')
call assert_equal(' 3 the theother', getline('.'))
1
" go to next match (still on line 3)
- call feedkeys("/the\<c-n>\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<C-G>\<cr>", 'tx')
call assert_equal(' 3 the theother', getline('.'))
1
" go to next match (still on line 3)
- call feedkeys("/the\<c-n>\<c-n>\<c-n>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<C-G>\<C-G>\<cr>", 'tx')
call assert_equal(' 3 the theother', getline('.'))
1
" go to previous match (on line 3)
- call feedkeys("/the\<c-n>\<c-n>\<c-n>\<c-p>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<cr>", 'tx')
call assert_equal(' 3 the theother', getline('.'))
1
" go to previous match (on line 3)
- call feedkeys("/the\<c-n>\<c-n>\<c-n>\<c-p>\<c-p>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<C-T>\<cr>", 'tx')
call assert_equal(' 3 the theother', getline('.'))
1
" go to previous match (on line 2)
- call feedkeys("/the\<c-n>\<c-n>\<c-n>\<c-p>\<c-p>\<c-p>\<cr>", 'tx')
+ call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<C-T>\<C-T>\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
" clean up
diff --git a/src/version.c b/src/version.c
index c64046e346..529b255cc9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2268,
+/**/
2267,
/**/
2266,