diff options
author | James McCoy <jamessan@jamessan.com> | 2017-06-25 11:01:16 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-06-26 22:08:11 -0400 |
commit | 0dd64556590633b2cab7cd846b28bbf5f7ef35d4 (patch) | |
tree | d66d8aa538c4bb929f55b0633a2e3a5b89e5db87 /src/nvim/ex_getln.c | |
parent | 518b42db916ccbb9057ca9361b48e83ea65bc3b9 (diff) | |
download | rneovim-0dd64556590633b2cab7cd846b28bbf5f7ef35d4.tar.gz rneovim-0dd64556590633b2cab7cd846b28bbf5f7ef35d4.tar.bz2 rneovim-0dd64556590633b2cab7cd846b28bbf5f7ef35d4.zip |
vim-patch:7.4.2268
Problem: Using CTRL-N and CTRL-P for incsearch shadows completion keys.
Solution: Use CTRL-T and CTRL-G instead.
https://github.com/vim/vim/commit/1195669f9e434fa9ab8b57ee9470bf951e4990b8
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 128 |
1 files changed, 66 insertions, 62 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index efa8cd24bc..62f802fb8f 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1282,72 +1282,12 @@ static int command_line_handle_key(CommandLineState *s) case Ctrl_N: // next match case Ctrl_P: // previous match - if (p_is && !cmd_silent && (s->firstc == '/' || s->firstc == '?')) { - pos_T t; - int search_flags = SEARCH_KEEP + SEARCH_NOOF + SEARCH_PEEK; - - if (char_avail()) { - return 1; - } - ui_busy_start(); - ui_flush(); - if (s->c == Ctrl_N) { - t = s->match_end; - search_flags += SEARCH_COL; - } else { - t = s->match_start; - } - emsg_off++; - s->i = searchit(curwin, curbuf, &t, - s->c == Ctrl_N ? FORWARD : BACKWARD, - ccline.cmdbuff, s->count, search_flags, - RE_SEARCH, 0, NULL); - emsg_off--; - ui_busy_stop(); - if (s->i) { - s->old_cursor = s->match_start; - s->match_end = t; - s->match_start = t; - if (s->c == Ctrl_P && s->firstc == '/') { - // move just before the current match, so that - // when nv_search finishes the cursor will be - // put back on the match - s->old_cursor = t; - (void)decl(&s->old_cursor); - } - if (lt(t, s->old_cursor) && s->c == Ctrl_N) { - // wrap around - s->old_cursor = t; - if (s->firstc == '?') { - (void)incl(&s->old_cursor); - } else { - (void)decl(&s->old_cursor); - } - } - - set_search_match(&s->match_end); - curwin->w_cursor = s->match_start; - changed_cline_bef_curs(); - update_topline(); - validate_cursor(); - highlight_match = true; - s->old_curswant = curwin->w_curswant; - s->old_leftcol = curwin->w_leftcol; - s->old_topline = curwin->w_topline; - s->old_topfill = curwin->w_topfill; - s->old_botline = curwin->w_botline; - update_screen(NOT_VALID); - redrawcmdline(); - } else { - vim_beep(BO_ERROR); - } - return command_line_not_changed(s); - } else if (s->xpc.xp_numfiles > 0) { + if (s->xpc.xp_numfiles > 0) { if (nextwild(&s->xpc, (s->c == Ctrl_P) ? WILD_PREV : WILD_NEXT, 0, s->firstc != '@') == FAIL) { break; } - return command_line_changed(s); + return command_line_not_changed(s); } // fallthrough @@ -1488,6 +1428,70 @@ static int command_line_handle_key(CommandLineState *s) beep_flush(); return command_line_not_changed(s); + case Ctrl_G: // next match + case Ctrl_T: // previous match + if (p_is && !cmd_silent && (s->firstc == '/' || s->firstc == '?')) { + pos_T t; + int search_flags = SEARCH_KEEP + SEARCH_NOOF + SEARCH_PEEK; + + if (char_avail()) { + return 1; + } + ui_busy_start(); + ui_flush(); + if (s->c == Ctrl_G) { + t = s->match_end; + search_flags += SEARCH_COL; + } else { + t = s->match_start; + } + emsg_off++; + s->i = searchit(curwin, curbuf, &t, + s->c == Ctrl_G ? FORWARD : BACKWARD, + ccline.cmdbuff, s->count, search_flags, + RE_SEARCH, 0, NULL); + emsg_off--; + ui_busy_stop(); + if (s->i) { + s->old_cursor = s->match_start; + s->match_end = t; + s->match_start = t; + if (s->c == Ctrl_T && s->firstc == '/') { + // move just before the current match, so that + // when nv_search finishes the cursor will be + // put back on the match + s->old_cursor = t; + (void)decl(&s->old_cursor); + } + if (lt(t, s->old_cursor) && s->c == Ctrl_G) { + // wrap around + s->old_cursor = t; + if (s->firstc == '?') { + (void)incl(&s->old_cursor); + } else { + (void)decl(&s->old_cursor); + } + } + + set_search_match(&s->match_end); + curwin->w_cursor = s->match_start; + changed_cline_bef_curs(); + update_topline(); + validate_cursor(); + highlight_match = true; + s->old_curswant = curwin->w_curswant; + s->old_leftcol = curwin->w_leftcol; + s->old_topline = curwin->w_topline; + s->old_topfill = curwin->w_topfill; + s->old_botline = curwin->w_botline; + update_screen(NOT_VALID); + redrawcmdline(); + } else { + vim_beep(BO_ERROR); + } + } + return command_line_not_changed(s); + case Ctrl_V: case Ctrl_Q: s->ignore_drag_release = true; |