diff options
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e845073c12..ae6d26227b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -345,7 +345,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags) // here. The value of 200 allows nested function calls, ":source", etc. // Allow 200 or 'maxfuncdepth', whatever is larger. if (call_depth >= 200 && call_depth >= p_mfd) { - emsg(_("E169: Command too recursive")); + emsg(_(e_command_too_recursive)); // When converting to an exception, we do not include the command name // since this is not an error of the specific command. do_errthrow((cstack_T *)NULL, NULL); @@ -1583,13 +1583,14 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er /// @param cmdinfo Command parse information void execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo) { + char *errormsg = NULL; + #define ERROR(msg) \ do { \ - emsg(msg); \ + errormsg = msg; \ goto end; \ } while (0) - char *errormsg = NULL; cmdmod_T save_cmdmod = cmdmod; cmdmod = cmdinfo->cmdmod; @@ -1648,7 +1649,7 @@ void execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo) // If filename expansion is enabled, expand filenames if (cmdinfo->magic.file) { if (expand_filename(eap, (char_u **)eap->cmdlinep, &errormsg) == FAIL) { - ERROR(errormsg); + goto end; } } @@ -1683,14 +1684,13 @@ void execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo) (eap->argt & EX_BUFUNL) != 0, false, false); eap->addr_count = 1; // Shift each argument by 1 - if (eap->args != NULL) { - for (size_t i = 0; i < eap->argc - 1; i++) { - eap->args[i] = eap->args[i + 1]; - } - // Make the last argument point to the NUL terminator at the end of string - eap->args[eap->argc - 1] = eap->args[eap->argc - 1] + eap->arglens[eap->argc - 1]; - eap->argc -= 1; + for (size_t i = 0; i < eap->argc - 1; i++) { + eap->args[i] = eap->args[i + 1]; } + // Make the last argument point to the NUL terminator at the end of string + eap->args[eap->argc - 1] = eap->args[eap->argc - 1] + eap->arglens[eap->argc - 1]; + eap->argc -= 1; + eap->arg = eap->args[0]; } if (eap->line2 < 0) { // failed @@ -1707,14 +1707,20 @@ void execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo) eap->errmsg = NULL; (cmdnames[eap->cmdidx].cmd_func)(eap); if (eap->errmsg != NULL) { - ERROR(_(eap->errmsg)); + errormsg = _(eap->errmsg); } } + end: + if (errormsg != NULL && *errormsg != NUL) { + emsg(errormsg); + } // Undo command modifiers undo_cmdmod(eap, msg_scroll); cmdmod = save_cmdmod; - + if (eap->did_sandbox) { + sandbox--; + } #undef ERROR } @@ -5522,6 +5528,11 @@ char *uc_validate_name(char *name) return name; } +/// Create a new user command {name}, if one doesn't already exist. +/// +/// This function takes ownership of compl_arg, compl_luaref, and luaref. +/// +/// @return OK if the command is created, FAIL otherwise. int uc_add_command(char *name, size_t name_len, char *rep, uint32_t argt, long def, int flags, int compl, char *compl_arg, LuaRef compl_luaref, cmd_addr_T addr_type, LuaRef luaref, bool force) @@ -8831,7 +8842,7 @@ static void ex_redraw(exarg_T *eap) ui_flush(); } -/// ":redrawstatus": force redraw of status line(s) +/// ":redrawstatus": force redraw of status line(s) and window bar(s) static void ex_redrawstatus(exarg_T *eap) { if (State & MODE_CMDPREVIEW) { @@ -8847,8 +8858,7 @@ static void ex_redrawstatus(exarg_T *eap) } else { status_redraw_curbuf(); } - update_screen(VIsual_active ? INVERTED : - 0); + update_screen(VIsual_active ? INVERTED : 0); RedrawingDisabled = r; p_lz = p; ui_flush(); @@ -8969,7 +8979,6 @@ bool save_current_state(save_state_T *sst) sst->save_restart_edit = restart_edit; sst->save_msg_didout = msg_didout; sst->save_State = State; - sst->save_insertmode = p_im; sst->save_finish_op = finish_op; sst->save_opcount = opcount; sst->save_reg_executing = reg_executing; @@ -8977,7 +8986,6 @@ bool save_current_state(save_state_T *sst) msg_scroll = false; // no msg scrolling in Normal mode restart_edit = 0; // don't go to Insert mode - p_im = false; // don't use 'insertmode // Save the current typeahead. This is required to allow using ":normal" // from an event handler and makes sure we don't hang when the argument @@ -9000,7 +9008,6 @@ void restore_current_state(save_state_T *sst) // override the value of restart_edit anyway. restart_edit = sst->save_restart_edit; } - p_im = sst->save_insertmode; finish_op = sst->save_finish_op; opcount = sst->save_opcount; reg_executing = sst->save_reg_executing; |