vim-patch:9.0.1298: inserting register on the cmdline does not trigger incsearch

Problem:    Inserting a register on the command line does not trigger
            incsearch or update hlsearch.
Solution:   Have cmdline_insert_reg() return CMDLINE_CHANGED when appropriate
            and handle it correctly. (Ken Takata, closes vim/vim#11960)

c4b7dec382

Co-authored-by: K.Takata <kentkt@csc.jp>
This commit is contained in:
zeertzjq
2023-02-11 18:44:06 +08:00
parent 7d58de11f4
commit 9437800d28
3 changed files with 54 additions and 14 deletions

View File

@@ -1598,8 +1598,10 @@ static int command_line_insert_reg(CommandLineState *s)
}
}
bool literally = false;
if (s->c != ESC) { // use ESC to cancel inserting register
cmdline_paste(s->c, i == Ctrl_R, false);
literally = i == Ctrl_R;
cmdline_paste(s->c, literally, false);
// When there was a serious error abort getting the
// command line.
@@ -1624,8 +1626,9 @@ static int command_line_insert_reg(CommandLineState *s)
ccline.special_char = NUL;
redrawcmd();
// The text has been stuffed, the command line didn't change yet.
return CMDLINE_NOT_CHANGED;
// The text has been stuffed, the command line didn't change yet, but it
// will change soon. The caller must take care of it.
return literally ? CMDLINE_NOT_CHANGED : CMDLINE_CHANGED;
}
/// Handle the Left and Right mouse clicks in the command-line mode.
@@ -1857,12 +1860,13 @@ static int command_line_handle_key(CommandLineState *s)
case Ctrl_R: // insert register
switch (command_line_insert_reg(s)) {
case CMDLINE_NOT_CHANGED:
return command_line_not_changed(s);
case GOTO_NORMAL_MODE:
return 0; // back to cmd mode
case CMDLINE_NOT_CHANGED:
s->is_state.incsearch_postponed = true;
FALLTHROUGH;
default:
return command_line_changed(s);
return command_line_not_changed(s);
}
case Ctrl_D: