aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 59962c153b..6864e2b914 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1536,8 +1536,9 @@ static char_u * do_one_cmd(char_u **cmdlinep,
}
ea.cmd = skipwhite(ea.cmd);
lnum = get_address(&ea, &ea.cmd, ea.addr_type, ea.skip, ea.addr_count == 0);
- if (ea.cmd == NULL) /* error detected */
+ if (ea.cmd == NULL) { // error detected
goto doend;
+ }
if (lnum == MAXLNUM) {
if (*ea.cmd == '%') { /* '%' - all lines */
++ea.cmd;
@@ -4640,14 +4641,14 @@ static struct {
char *name;
} addr_type_complete[] =
{
- {ADDR_ARGUMENTS, "arguments"},
- {ADDR_LINES, "lines"},
- {ADDR_LOADED_BUFFERS, "loaded_buffers"},
- {ADDR_TABS, "tabs"},
- {ADDR_BUFFERS, "buffers"},
- {ADDR_WINDOWS, "windows"},
- {ADDR_QUICKFIX, "quickfix"},
- {-1, NULL}
+ { ADDR_ARGUMENTS, "arguments" },
+ { ADDR_LINES, "lines" },
+ { ADDR_LOADED_BUFFERS, "loaded_buffers" },
+ { ADDR_TABS, "tabs" },
+ { ADDR_BUFFERS, "buffers" },
+ { ADDR_WINDOWS, "windows" },
+ { ADDR_QUICKFIX, "quickfix" },
+ { -1, NULL }
};
/*
@@ -6865,6 +6866,9 @@ void post_chdir(CdScope scope)
curwin->w_localdir = vim_strsave(NameBuff);
}
break;
+ case kCdScopeInvalid:
+ // We should never get here
+ assert(false);
}
shorten_fnames(TRUE);
@@ -6992,7 +6996,7 @@ void do_sleep(long msec)
ui_flush(); // flush before waiting
for (long left = msec; !got_int && left > 0; left -= 1000L) {
int next = left > 1000l ? 1000 : (int)left;
- LOOP_PROCESS_EVENTS_UNTIL(&loop, loop.events, (int)next, got_int);
+ LOOP_PROCESS_EVENTS_UNTIL(&main_loop, main_loop.events, (int)next, got_int);
os_breakcheck();
}
}
@@ -7122,8 +7126,8 @@ static void ex_put(exarg_T *eap)
eap->forceit = TRUE;
}
curwin->w_cursor.lnum = eap->line2;
- do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L,
- PUT_LINE|PUT_CURSLINE);
+ do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1,
+ PUT_LINE|PUT_CURSLINE);
}
/*
@@ -7132,7 +7136,7 @@ static void ex_put(exarg_T *eap)
static void ex_copymove(exarg_T *eap)
{
long n = get_address(eap, &eap->arg, eap->addr_type, false, false);
- if (eap->arg == NULL) { /* error detected */
+ if (eap->arg == NULL) { // error detected
eap->nextcmd = NULL;
return;
}
@@ -7351,10 +7355,11 @@ static void ex_redir(exarg_T *eap)
/* Can use both "@a" and "@a>". */
if (*arg == '>')
arg++;
- /* Make register empty when not using @A-@Z and the
- * command is valid. */
- if (*arg == NUL && !isupper(redir_reg))
- write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
+ // Make register empty when not using @A-@Z and the
+ // command is valid.
+ if (*arg == NUL && !isupper(redir_reg)) {
+ write_reg_contents(redir_reg, (char_u *)"", 0, false);
+ }
}
}
if (*arg != NUL) {
@@ -7855,19 +7860,26 @@ static void ex_stopinsert(exarg_T *eap)
*/
void exec_normal_cmd(char_u *cmd, int remap, bool silent)
{
+ // Stuff the argument into the typeahead buffer.
+ ins_typebuf(cmd, remap, 0, true, silent);
+ exec_normal(false);
+}
+
+/// Execute normal_cmd() until there is no typeahead left.
+///
+/// @param was_typed whether or not something was typed
+void exec_normal(bool was_typed)
+{
oparg_T oa;
- /*
- * Stuff the argument into the typeahead buffer.
- * Execute normal_cmd() until there is no typeahead left.
- */
clear_oparg(&oa);
- finish_op = FALSE;
- ins_typebuf(cmd, remap, 0, TRUE, silent);
- while ((!stuff_empty() || (!typebuf_typed() && typebuf.tb_len > 0))
+ finish_op = false;
+ while ((!stuff_empty()
+ || ((was_typed || !typebuf_typed())
+ && typebuf.tb_len > 0))
&& !got_int) {
update_topline_cursor();
- normal_cmd(&oa, TRUE); /* execute a Normal mode cmd */
+ normal_cmd(&oa, true); // execute a Normal mode cmd
}
}