diff options
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 40b4cc6d79..07aab3307a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -443,14 +443,8 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) } } - if (s->gotesc) { // abandon command line - xfree(ccline.cmdbuff); - ccline.cmdbuff = NULL; - if (msg_scrolled == 0) { - compute_cmdrow(); - } - MSG(""); - redraw_cmdline = true; + if (s->gotesc) { + abandon_cmdline(); } } @@ -1062,6 +1056,12 @@ static void command_line_next_incsearch(CommandLineState *s, bool next_match) // put back on the match s->search_start = t; (void)decl(&s->search_start); + } else if (next_match && s->firstc == '?') { + // move just after the current match, so that + // when nv_search finishes the cursor will be + // put back on the match + s->search_start = t; + (void)incl(&s->search_start); } if (lt(t, s->search_start) && next_match) { // wrap around @@ -1549,7 +1549,7 @@ static int command_line_handle_key(CommandLineState *s) } if (s->c != NUL) { if (s->c == s->firstc - || vim_strchr((char_u *)(p_magic ? "\\^$.*[" : "\\^$"), s->c) + || vim_strchr((char_u *)(p_magic ? "\\~^$.*[" : "\\^$"), s->c) != NULL) { // put a backslash before special characters stuffcharReadbuff(s->c); @@ -1673,9 +1673,6 @@ static int command_line_handle_key(CommandLineState *s) case Ctrl_G: // next match case Ctrl_T: // previous match if (p_is && !cmd_silent && (s->firstc == '/' || s->firstc == '?')) { - if (char_avail()) { - return 1; - } if (ccline.cmdlen != 0) { command_line_next_incsearch(s, s->c == Ctrl_G); } @@ -1941,6 +1938,18 @@ static int command_line_changed(CommandLineState *s) return 1; } +/// Abandon the command line. +static void abandon_cmdline(void) +{ + xfree(ccline.cmdbuff); + ccline.cmdbuff = NULL; + if (msg_scrolled == 0) { + compute_cmdrow(); + } + MSG(""); + redraw_cmdline = true; +} + /* * getcmdline() - accept a command line starting with firstc. * |