To: vim_dev@googlegroups.com Subject: Patch 7.4.2268 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2268 (after 7.4.2259) Problem: Using CTRL-N and CTRL-P for incsearch shadows completion keys. Solution: Use CTRL-T and CTRL-G instead. Files: runtime/doc/cmdline.txt, src/ex_getln.c, src/testdir/test_search.vim *** ../vim-7.4.2267/runtime/doc/cmdline.txt 2016-08-26 19:13:02.107897102 +0200 --- runtime/doc/cmdline.txt 2016-08-27 16:05:20.606700752 +0200 *************** *** 404,422 **** *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) *c_CTRL-P* *c_* CTRL-P After using 'wildchar' which got multiple matches, go to previous match. Otherwise recall older command-line from history. 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. --- 409,419 ---- *************** *** 426,437 **** --- 423,448 ---- If there are multiple matches the longest common part is inserted in place of the pattern. If the result is shorter than the pattern, no completion is done. + */_CTRL-L* When 'incsearch' is set, entering a search pattern for "/" or "?" and the current match is displayed then CTRL-L will add one character from the end of the current match. 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 (CTRL-E when in Vi compatible mode; in a previous version was used). In the pattern standard wildcards '*' and *** ../vim-7.4.2267/src/ex_getln.c 2016-08-26 19:55:57.205594548 +0200 --- src/ex_getln.c 2016-08-27 16:23:29.389477077 +0200 *************** *** 1503,1584 **** 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; } #ifdef FEAT_CMDHIST case K_UP: --- 1503,1516 ---- case Ctrl_N: /* next match */ case Ctrl_P: /* previous match */ if (xpc.xp_numfiles > 0) { if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, 0, firstc != '@') == FAIL) break; ! goto cmdline_not_changed; } + /* FALLTHROUGH */ #ifdef FEAT_CMDHIST case K_UP: *************** *** 1722,1727 **** --- 1654,1730 ---- 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 *** ../vim-7.4.2267/src/testdir/test_search.vim 2016-08-26 19:13:02.115897031 +0200 --- src/testdir/test_search.vim 2016-08-27 16:21:06.126684832 +0200 *************** *** 16,26 **** call feedkeys("/foobar\", 'tx') call feedkeys("/the\",'tx') call assert_equal('the', @/) ! call feedkeys("/thes\\\",'tx') call assert_equal('foobar', @/) " Test 2 ! " Ctrl-N goes from one match to the next " until the end of the buffer set incsearch nowrapscan :1 --- 16,26 ---- call feedkeys("/foobar\", 'tx') call feedkeys("/the\",'tx') call assert_equal('the', @/) ! call feedkeys("/thes\\\",'tx') call assert_equal('foobar', @/) " Test 2 ! " Ctrl-G goes from one match to the next " until the end of the buffer set incsearch nowrapscan :1 *************** *** 29,67 **** call assert_equal(' 2 these', getline('.')) :1 " second match ! call feedkeys("/the\\", 'tx') call assert_equal(' 3 the', getline('.')) :1 " third match ! call feedkeys("/the".repeat("\", 2)."\", 'tx') call assert_equal(' 4 their', getline('.')) :1 " fourth match ! call feedkeys("/the".repeat("\", 3)."\", 'tx') call assert_equal(' 5 there', getline('.')) :1 " fifth match ! call feedkeys("/the".repeat("\", 4)."\", 'tx') call assert_equal(' 6 their', getline('.')) :1 " sixth match ! call feedkeys("/the".repeat("\", 5)."\", 'tx') call assert_equal(' 7 the', getline('.')) :1 " seventh match ! call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 " eigth match ! call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 " no further match ! call feedkeys("/the".repeat("\", 8)."\", 'tx') call assert_equal(' 9 these', getline('.')) " Test 3 ! " Ctrl-N goes from one match to the next " and continues back at the top set incsearch wrapscan :1 --- 29,67 ---- call assert_equal(' 2 these', getline('.')) :1 " second match ! call feedkeys("/the\\", 'tx') call assert_equal(' 3 the', getline('.')) :1 " third match ! call feedkeys("/the".repeat("\", 2)."\", 'tx') call assert_equal(' 4 their', getline('.')) :1 " fourth match ! call feedkeys("/the".repeat("\", 3)."\", 'tx') call assert_equal(' 5 there', getline('.')) :1 " fifth match ! call feedkeys("/the".repeat("\", 4)."\", 'tx') call assert_equal(' 6 their', getline('.')) :1 " sixth match ! call feedkeys("/the".repeat("\", 5)."\", 'tx') call assert_equal(' 7 the', getline('.')) :1 " seventh match ! call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 " eigth match ! call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 " no further match ! call feedkeys("/the".repeat("\", 8)."\", 'tx') call assert_equal(' 9 these', getline('.')) " Test 3 ! " Ctrl-G goes from one match to the next " and continues back at the top set incsearch wrapscan :1 *************** *** 70,108 **** call assert_equal(' 2 these', getline('.')) :1 " second match ! call feedkeys("/the\\", 'tx') call assert_equal(' 3 the', getline('.')) :1 " third match ! call feedkeys("/the".repeat("\", 2)."\", 'tx') call assert_equal(' 4 their', getline('.')) :1 " fourth match ! call feedkeys("/the".repeat("\", 3)."\", 'tx') call assert_equal(' 5 there', getline('.')) :1 " fifth match ! call feedkeys("/the".repeat("\", 4)."\", 'tx') call assert_equal(' 6 their', getline('.')) :1 " sixth match ! call feedkeys("/the".repeat("\", 5)."\", 'tx') call assert_equal(' 7 the', getline('.')) :1 " seventh match ! call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 " eigth match ! call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 " back at first match ! call feedkeys("/the".repeat("\", 8)."\", 'tx') call assert_equal(' 2 these', getline('.')) " Test 4 ! " CTRL-P goes to the previous match set incsearch nowrapscan $ " first match --- 70,108 ---- call assert_equal(' 2 these', getline('.')) :1 " second match ! call feedkeys("/the\\", 'tx') call assert_equal(' 3 the', getline('.')) :1 " third match ! call feedkeys("/the".repeat("\", 2)."\", 'tx') call assert_equal(' 4 their', getline('.')) :1 " fourth match ! call feedkeys("/the".repeat("\", 3)."\", 'tx') call assert_equal(' 5 there', getline('.')) :1 " fifth match ! call feedkeys("/the".repeat("\", 4)."\", 'tx') call assert_equal(' 6 their', getline('.')) :1 " sixth match ! call feedkeys("/the".repeat("\", 5)."\", 'tx') call assert_equal(' 7 the', getline('.')) :1 " seventh match ! call feedkeys("/the".repeat("\", 6)."\", 'tx') call assert_equal(' 8 them', getline('.')) :1 " eigth match ! call feedkeys("/the".repeat("\", 7)."\", 'tx') call assert_equal(' 9 these', getline('.')) :1 " back at first match ! call feedkeys("/the".repeat("\", 8)."\", 'tx') call assert_equal(' 2 these', getline('.')) " Test 4 ! " CTRL-T goes to the previous match set incsearch nowrapscan $ " first match *************** *** 110,132 **** call assert_equal(' 9 these', getline('.')) $ " first match ! call feedkeys("?the\\", 'tx') call assert_equal(' 9 these', getline('.')) $ " second match ! call feedkeys("?the".repeat("\", 1)."\", 'tx') call assert_equal(' 8 them', getline('.')) $ " last match ! call feedkeys("?the".repeat("\", 7)."\", 'tx') call assert_equal(' 2 these', getline('.')) $ " last match ! call feedkeys("?the".repeat("\", 8)."\", 'tx') call assert_equal(' 2 these', getline('.')) " Test 5 ! " CTRL-P goes to the previous match set incsearch wrapscan $ " first match --- 110,132 ---- call assert_equal(' 9 these', getline('.')) $ " first match ! call feedkeys("?the\\", 'tx') call assert_equal(' 9 these', getline('.')) $ " second match ! call feedkeys("?the".repeat("\", 1)."\", 'tx') call assert_equal(' 8 them', getline('.')) $ " last match ! call feedkeys("?the".repeat("\", 7)."\", 'tx') call assert_equal(' 2 these', getline('.')) $ " last match ! call feedkeys("?the".repeat("\", 8)."\", 'tx') call assert_equal(' 2 these', getline('.')) " Test 5 ! " CTRL-T goes to the previous match set incsearch wrapscan $ " first match *************** *** 134,152 **** call assert_equal(' 9 these', getline('.')) $ " first match at the top ! call feedkeys("?the\\", 'tx') call assert_equal(' 2 these', getline('.')) $ " second match ! call feedkeys("?the".repeat("\", 1)."\", 'tx') call assert_equal(' 8 them', getline('.')) $ " last match ! call feedkeys("?the".repeat("\", 7)."\", 'tx') call assert_equal(' 2 these', getline('.')) $ " back at the bottom of the buffer ! call feedkeys("?the".repeat("\", 8)."\", 'tx') call assert_equal(' 9 these', getline('.')) " Test 6 --- 134,152 ---- call assert_equal(' 9 these', getline('.')) $ " first match at the top ! call feedkeys("?the\\", 'tx') call assert_equal(' 2 these', getline('.')) $ " second match ! call feedkeys("?the".repeat("\", 1)."\", 'tx') call assert_equal(' 8 them', getline('.')) $ " last match ! call feedkeys("?the".repeat("\", 7)."\", 'tx') call assert_equal(' 2 these', getline('.')) $ " back at the bottom of the buffer ! call feedkeys("?the".repeat("\", 8)."\", 'tx') call assert_equal(' 9 these', getline('.')) " Test 6 *************** *** 158,173 **** call assert_equal(' 2 these', getline('.')) 1 " go to next match of 'thes' ! call feedkeys("/the\\\", 'tx') call assert_equal(' 9 these', getline('.')) 1 " wrap around ! call feedkeys("/the\\\\", 'tx') call assert_equal(' 2 these', getline('.')) 1 " wrap around set nowrapscan ! call feedkeys("/the\\\\", 'tx') call assert_equal(' 9 these', getline('.')) " Test 7 --- 158,173 ---- call assert_equal(' 2 these', getline('.')) 1 " go to next match of 'thes' ! call feedkeys("/the\\\", 'tx') call assert_equal(' 9 these', getline('.')) 1 " wrap around ! call feedkeys("/the\\\\", 'tx') call assert_equal(' 2 these', getline('.')) 1 " wrap around set nowrapscan ! call feedkeys("/the\\\\", 'tx') call assert_equal(' 9 these', getline('.')) " Test 7 *************** *** 183,189 **** call assert_equal(' 9 these', getline('.')) 1 " delete one char, add another, go to previous match, add one char ! call feedkeys("/thei\s\\\\", 'tx') call assert_equal(' 8 them', getline('.')) 1 " delete all chars, start from the beginning again --- 183,189 ---- call assert_equal(' 9 these', getline('.')) 1 " delete one char, add another, go to previous match, add one char ! call feedkeys("/thei\s\\\\", 'tx') call assert_equal(' 8 them', getline('.')) 1 " delete all chars, start from the beginning again *************** *** 205,211 **** new call setline(1, [' 1', ' 2 these', ' 3 the theother']) " Test 1 ! " Ctrl-P goes correctly back and forth set incsearch 1 " first match --- 205,211 ---- new call setline(1, [' 1', ' 2 these', ' 3 the theother']) " Test 1 ! " Ctrl-T goes correctly back and forth set incsearch 1 " first match *************** *** 213,239 **** call assert_equal(' 2 these', getline('.')) 1 " go to next match (on next line) ! call feedkeys("/the\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to next match (still on line 3) ! call feedkeys("/the\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to next match (still on line 3) ! call feedkeys("/the\\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to previous match (on line 3) ! call feedkeys("/the\\\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to previous match (on line 3) ! call feedkeys("/the\\\\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to previous match (on line 2) ! call feedkeys("/the\\\\\\\", 'tx') call assert_equal(' 2 these', getline('.')) " clean up --- 213,239 ---- call assert_equal(' 2 these', getline('.')) 1 " go to next match (on next line) ! call feedkeys("/the\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to next match (still on line 3) ! call feedkeys("/the\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to next match (still on line 3) ! call feedkeys("/the\\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to previous match (on line 3) ! call feedkeys("/the\\\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to previous match (on line 3) ! call feedkeys("/the\\\\\\", 'tx') call assert_equal(' 3 the theother', getline('.')) 1 " go to previous match (on line 2) ! call feedkeys("/the\\\\\\\", 'tx') call assert_equal(' 2 these', getline('.')) " clean up *** ../vim-7.4.2267/src/version.c 2016-08-27 15:41:28.890869493 +0200 --- src/version.c 2016-08-27 16:08:14.861212277 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2268, /**/ -- From "know your smileys": ...---... SOS /// 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 ///