aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index c4169f03f0..3093caebaf 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -95,19 +95,21 @@ typedef struct command_line_state {
char_u *lookfor; // string to match
int hiscnt; // current history line in use
int histype; // history type to be used
- pos_T old_cursor;
- colnr_T old_curswant;
- colnr_T old_leftcol;
- linenr_T old_topline;
- int old_topfill;
- linenr_T old_botline;
+ pos_T old_cursor;
+ colnr_T old_curswant;
+ colnr_T old_leftcol;
+ linenr_T old_topline;
+ int old_topfill;
+ linenr_T old_botline;
int did_incsearch;
int incsearch_postponed;
+ bool live; // performing 'inccommand' preview
int did_wild_list; // did wild_list() recently
int wim_index; // index in wim_flags[]
int res;
- int save_msg_scroll;
- int save_State; // remember State when called
+ int save_msg_scroll;
+ int save_State; // remember State when called
+ char_u *save_p_icm;
int some_key_typed; // one of the keys was typed
// mouse drag and release events are ignored, unless they are
// preceded with a mouse down event
@@ -159,6 +161,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
s->indent = indent;
s->save_msg_scroll = msg_scroll;
s->save_State = State;
+ s->save_p_icm = vim_strsave(p_icm);
s->ignore_drag_release = true;
if (s->firstc == -1) {
@@ -323,9 +326,12 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
need_wait_return = false;
}
+ set_string_option_direct((char_u *)"icm", -1, s->save_p_icm, OPT_FREE,
+ SID_NONE);
State = s->save_State;
setmouse();
ui_cursor_shape(); // may show different cursor shape
+ xfree(s->save_p_icm);
{
char_u *p = ccline.cmdbuff;
@@ -394,7 +400,8 @@ static int command_line_execute(VimState *state, int key)
if ((s->c == Ctrl_C)
&& s->firstc != '@'
&& !s->break_ctrl_c
- && !global_busy) {
+ && !global_busy
+ && !cmd_is_live(ccline.cmdbuff)) {
got_int = false;
}
@@ -981,7 +988,6 @@ static int command_line_handle_key(CommandLineState *s)
status_redraw_curbuf();
return command_line_not_changed(s);
- // case '@': only in very old vi
case Ctrl_U:
// delete all characters left of the cursor
s->j = ccline.cmdpos;
@@ -996,7 +1002,6 @@ static int command_line_handle_key(CommandLineState *s)
redrawcmd();
return command_line_changed(s);
-
case ESC: // get here if p_wc != ESC or when ESC typed twice
case Ctrl_C:
// In exmode it doesn't make sense to return. Except when
@@ -1489,11 +1494,11 @@ static int command_line_handle_key(CommandLineState *s)
static int command_line_not_changed(CommandLineState *s)
{
- // This part implements incremental searches for "/" and "?" Jump to
- // cmdline_not_changed when a character has been read but the command line
- // did not change. Then we only search and redraw if something changed in
- // the past. Jump to cmdline_changed when the command line did change.
- // (Sorry for the goto's, I know it is ugly).
+ // Incremental searches for "/" and "?":
+ // Enter command_line_not_changed() when a character has been read but the
+ // command line did not change. Then we only search and redraw if something
+ // changed in the past.
+ // Enter command_line_changed() when the command line did change.
if (!s->incsearch_postponed) {
return 1;
}
@@ -1592,11 +1597,13 @@ static int command_line_changed(CommandLineState *s)
redrawcmdline();
s->did_incsearch = true;
} else if (s->firstc == ':'
- && KeyTyped // only if interactive
+ && current_SID == 0 // only if interactive
&& *p_icm != NUL // 'inccommand' is set
&& curbuf->b_p_ma // buffer is modifiable
&& cmdline_star == 0 // not typing a password
- && cmd_is_live(ccline.cmdbuff)) {
+ && cmd_is_live(ccline.cmdbuff)
+ && !vpeekc_any()) {
+ s->live = true;
// process a "live" command ('inccommand')
do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_LIVE);
@@ -1610,6 +1617,9 @@ static int command_line_changed(CommandLineState *s)
update_topline();
redrawcmdline();
+ } else if (s->live) {
+ s->live = false;
+ update_screen(SOME_VALID); // Clear 'inccommand' preview.
}
if (cmdmsg_rl || (p_arshape && !p_tbidi && enc_utf8)) {