mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 08:48:16 +00:00
vim-patch:8.2.1897: command modifiers are saved and set inconsistently
Problem: Command modifiers are saved and set inconsistently.
Solution: Separate parsing and applying command modifiers. Save values in
cmdmod_T.
5661ed6c83
Cherry-pick: :0verbose fix from patch 8.2.4741
This commit is contained in:
@@ -284,8 +284,6 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
|||||||
{
|
{
|
||||||
exarg_T ea;
|
exarg_T ea;
|
||||||
memset(&ea, 0, sizeof(ea));
|
memset(&ea, 0, sizeof(ea));
|
||||||
ea.verbose_save = -1;
|
|
||||||
ea.save_msg_silent = -1;
|
|
||||||
|
|
||||||
CmdParseInfo cmdinfo;
|
CmdParseInfo cmdinfo;
|
||||||
memset(&cmdinfo, 0, sizeof(cmdinfo));
|
memset(&cmdinfo, 0, sizeof(cmdinfo));
|
||||||
@@ -514,9 +512,9 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
|||||||
if (HAS_KEY(mods.verbose)) {
|
if (HAS_KEY(mods.verbose)) {
|
||||||
if (mods.verbose.type != kObjectTypeInteger) {
|
if (mods.verbose.type != kObjectTypeInteger) {
|
||||||
VALIDATION_ERROR("'mods.verbose' must be a Integer");
|
VALIDATION_ERROR("'mods.verbose' must be a Integer");
|
||||||
} else if (mods.verbose.data.integer >= 0) {
|
} else if ((int)mods.verbose.data.integer >= 0) {
|
||||||
// Silently ignore negative integers to allow mods.verbose to be set to -1.
|
// Silently ignore negative integers to allow mods.verbose to be set to -1.
|
||||||
cmdinfo.verbose = mods.verbose.data.integer;
|
cmdinfo.verbose = (int)mods.verbose.data.integer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,7 +660,7 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
|
|||||||
kv_printf(cmdline, "%dtab ", cmdinfo->cmdmod.tab - 1);
|
kv_printf(cmdline, "%dtab ", cmdinfo->cmdmod.tab - 1);
|
||||||
}
|
}
|
||||||
if (cmdinfo->verbose != -1) {
|
if (cmdinfo->verbose != -1) {
|
||||||
kv_printf(cmdline, "%ldverbose ", cmdinfo->verbose);
|
kv_printf(cmdline, "%dverbose ", cmdinfo->verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdinfo->emsg_silent) {
|
if (cmdinfo->emsg_silent) {
|
||||||
|
@@ -209,10 +209,6 @@ struct exarg {
|
|||||||
LineGetter getline; ///< Function used to get the next line
|
LineGetter getline; ///< Function used to get the next line
|
||||||
void *cookie; ///< argument for getline()
|
void *cookie; ///< argument for getline()
|
||||||
cstack_T *cstack; ///< condition stack for ":if" etc.
|
cstack_T *cstack; ///< condition stack for ":if" etc.
|
||||||
long verbose_save; ///< saved value of p_verbose
|
|
||||||
int save_msg_silent; ///< saved value of msg_silent
|
|
||||||
int did_esilent; ///< how many times emsg_silent was incremented
|
|
||||||
bool did_sandbox; ///< when true did sandbox++
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FORCE_BIN 1 // ":edit ++bin file"
|
#define FORCE_BIN 1 // ":edit ++bin file"
|
||||||
@@ -251,6 +247,7 @@ struct expand {
|
|||||||
/// flag. This needs to be saved for recursive commands, put them in a
|
/// flag. This needs to be saved for recursive commands, put them in a
|
||||||
/// structure for easy manipulation.
|
/// structure for easy manipulation.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int cmod_flags; ///< CMOD_ flags, see below
|
||||||
int split; ///< flags for win_split()
|
int split; ///< flags for win_split()
|
||||||
int tab; ///< > 0 when ":tab" was used
|
int tab; ///< > 0 when ":tab" was used
|
||||||
bool browse; ///< true to invoke file dialog
|
bool browse; ///< true to invoke file dialog
|
||||||
@@ -262,18 +259,32 @@ typedef struct {
|
|||||||
bool keeppatterns; ///< true when ":keeppatterns" was used
|
bool keeppatterns; ///< true when ":keeppatterns" was used
|
||||||
bool lockmarks; ///< true when ":lockmarks" was used
|
bool lockmarks; ///< true when ":lockmarks" was used
|
||||||
bool noswapfile; ///< true when ":noswapfile" was used
|
bool noswapfile; ///< true when ":noswapfile" was used
|
||||||
char *save_ei; ///< saved value of 'eventignore'
|
|
||||||
regmatch_T filter_regmatch; ///< set by :filter /pat/
|
regmatch_T filter_regmatch; ///< set by :filter /pat/
|
||||||
bool filter_force; ///< set for :filter!
|
bool filter_force; ///< set for :filter!
|
||||||
|
|
||||||
|
int cmod_verbose; ///< non-zero to set 'verbose', -1 is used for zero override
|
||||||
|
|
||||||
|
// values for undo_cmdmod()
|
||||||
|
char_u *cmod_save_ei; ///< saved value of 'eventignore'
|
||||||
|
int cmod_did_sandbox; ///< set when "sandbox" was incremented
|
||||||
|
long cmod_verbose_save; ///< if 'verbose' was set: value of p_verbose plus one
|
||||||
|
int cmod_save_msg_silent; ///< if non-zero: saved value of msg_silent + 1
|
||||||
|
int cmod_did_esilent; ///< incremented when emsg_silent is
|
||||||
} cmdmod_T;
|
} cmdmod_T;
|
||||||
|
|
||||||
|
#define CMOD_SANDBOX 0x01
|
||||||
|
#define CMOD_SILENT 0x02
|
||||||
|
#define CMOD_ERRSILENT 0x04
|
||||||
|
#define CMOD_UNSILENT 0x08
|
||||||
|
#define CMOD_NOAUTOCMD 0x10
|
||||||
|
|
||||||
/// Stores command modifier info used by `nvim_parse_cmd`
|
/// Stores command modifier info used by `nvim_parse_cmd`
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool silent;
|
bool silent;
|
||||||
bool emsg_silent;
|
bool emsg_silent;
|
||||||
bool sandbox;
|
bool sandbox;
|
||||||
bool noautocmd;
|
bool noautocmd;
|
||||||
long verbose;
|
int verbose; ///< unlike cmod_verbose, -1 is used when unspecified and 0 for zero override
|
||||||
cmdmod_T cmdmod;
|
cmdmod_T cmdmod;
|
||||||
struct {
|
struct {
|
||||||
bool file;
|
bool file;
|
||||||
|
@@ -1431,31 +1431,12 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
|
|||||||
}
|
}
|
||||||
after_modifier = eap->cmd;
|
after_modifier = eap->cmd;
|
||||||
|
|
||||||
// Revert the side-effects of `parse_command_modifiers`
|
cmdinfo->silent = cmdmod.cmod_flags & CMOD_SILENT;
|
||||||
if (eap->save_msg_silent != -1) {
|
cmdinfo->emsg_silent = cmdmod.cmod_flags & CMOD_ERRSILENT;
|
||||||
cmdinfo->silent = !!msg_silent;
|
cmdinfo->sandbox = cmdmod.cmod_flags & CMOD_SANDBOX;
|
||||||
msg_silent = eap->save_msg_silent;
|
cmdinfo->noautocmd = cmdmod.cmod_flags & CMOD_NOAUTOCMD;
|
||||||
eap->save_msg_silent = -1;
|
if (cmdmod.cmod_verbose != 0) {
|
||||||
}
|
cmdinfo->verbose = cmdmod.cmod_verbose < 0 ? 0 : cmdmod.cmod_verbose;
|
||||||
if (eap->did_esilent) {
|
|
||||||
cmdinfo->emsg_silent = true;
|
|
||||||
emsg_silent--;
|
|
||||||
eap->did_esilent = false;
|
|
||||||
}
|
|
||||||
if (eap->did_sandbox) {
|
|
||||||
cmdinfo->sandbox = true;
|
|
||||||
sandbox--;
|
|
||||||
eap->did_sandbox = false;
|
|
||||||
}
|
|
||||||
if (cmdmod.save_ei != NULL) {
|
|
||||||
cmdinfo->noautocmd = true;
|
|
||||||
set_string_option_direct("ei", -1, (char_u *)cmdmod.save_ei, OPT_FREE, SID_NONE);
|
|
||||||
free_string_option((char_u *)cmdmod.save_ei);
|
|
||||||
}
|
|
||||||
if (eap->verbose_save != -1) {
|
|
||||||
cmdinfo->verbose = p_verbose;
|
|
||||||
p_verbose = eap->verbose_save;
|
|
||||||
eap->verbose_save = -1;
|
|
||||||
} else {
|
} else {
|
||||||
cmdinfo->verbose = -1;
|
cmdinfo->verbose = -1;
|
||||||
}
|
}
|
||||||
@@ -1586,25 +1567,21 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
|
|||||||
|
|
||||||
// Apply command modifiers
|
// Apply command modifiers
|
||||||
if (cmdinfo->silent) {
|
if (cmdinfo->silent) {
|
||||||
eap->save_msg_silent = msg_silent;
|
cmdmod.cmod_flags |= CMOD_SILENT;
|
||||||
msg_silent++;
|
|
||||||
}
|
}
|
||||||
if (cmdinfo->emsg_silent) {
|
if (cmdinfo->emsg_silent) {
|
||||||
eap->did_esilent = true;
|
cmdmod.cmod_flags |= CMOD_ERRSILENT;
|
||||||
emsg_silent++;
|
|
||||||
}
|
}
|
||||||
if (cmdinfo->sandbox) {
|
if (cmdinfo->sandbox) {
|
||||||
eap->did_sandbox = true;
|
cmdmod.cmod_flags |= CMOD_SANDBOX;
|
||||||
sandbox++;
|
|
||||||
}
|
}
|
||||||
if (cmdinfo->noautocmd) {
|
if (cmdinfo->noautocmd) {
|
||||||
cmdmod.save_ei = (char *)vim_strsave(p_ei);
|
cmdmod.cmod_flags |= CMOD_NOAUTOCMD;
|
||||||
set_string_option_direct("ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
|
|
||||||
}
|
}
|
||||||
if (cmdinfo->verbose != -1) {
|
if (cmdinfo->verbose >= 0) {
|
||||||
eap->verbose_save = p_verbose;
|
cmdmod.cmod_verbose = cmdinfo->verbose == 0 ? -1 : cmdinfo->verbose;
|
||||||
p_verbose = cmdinfo->verbose;
|
|
||||||
}
|
}
|
||||||
|
apply_cmdmod(&cmdmod);
|
||||||
|
|
||||||
if (!MODIFIABLE(curbuf) && (eap->argt & EX_MODIFY)
|
if (!MODIFIABLE(curbuf) && (eap->argt & EX_MODIFY)
|
||||||
// allow :put in terminals
|
// allow :put in terminals
|
||||||
@@ -1712,11 +1689,8 @@ end:
|
|||||||
emsg(errormsg);
|
emsg(errormsg);
|
||||||
}
|
}
|
||||||
// Undo command modifiers
|
// Undo command modifiers
|
||||||
undo_cmdmod(eap, msg_scroll);
|
undo_cmdmod(msg_scroll);
|
||||||
cmdmod = save_cmdmod;
|
cmdmod = save_cmdmod;
|
||||||
if (eap->did_sandbox) {
|
|
||||||
sandbox--;
|
|
||||||
}
|
|
||||||
return retv;
|
return retv;
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
}
|
}
|
||||||
@@ -1791,6 +1765,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
|
|||||||
if (parse_command_modifiers(&ea, &errormsg, false) == FAIL) {
|
if (parse_command_modifiers(&ea, &errormsg, false) == FAIL) {
|
||||||
goto doend;
|
goto doend;
|
||||||
}
|
}
|
||||||
|
apply_cmdmod(&cmdmod);
|
||||||
|
|
||||||
after_modifier = ea.cmd;
|
after_modifier = ea.cmd;
|
||||||
|
|
||||||
@@ -2337,12 +2312,12 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
|
|||||||
|
|
||||||
// The :try command saves the emsg_silent flag, reset it here when
|
// The :try command saves the emsg_silent flag, reset it here when
|
||||||
// ":silent! try" was used, it should only apply to :try itself.
|
// ":silent! try" was used, it should only apply to :try itself.
|
||||||
if (ea.cmdidx == CMD_try && ea.did_esilent > 0) {
|
if (ea.cmdidx == CMD_try && cmdmod.cmod_did_esilent > 0) {
|
||||||
emsg_silent -= ea.did_esilent;
|
emsg_silent -= cmdmod.cmod_did_esilent;
|
||||||
if (emsg_silent < 0) {
|
if (emsg_silent < 0) {
|
||||||
emsg_silent = 0;
|
emsg_silent = 0;
|
||||||
}
|
}
|
||||||
ea.did_esilent = 0;
|
cmdmod.cmod_did_esilent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. Execute the command.
|
// 7. Execute the command.
|
||||||
@@ -2402,15 +2377,11 @@ doend:
|
|||||||
(ea.cmdidx != CMD_SIZE
|
(ea.cmdidx != CMD_SIZE
|
||||||
&& !IS_USER_CMDIDX(ea.cmdidx)) ? cmdnames[(int)ea.cmdidx].cmd_name : NULL);
|
&& !IS_USER_CMDIDX(ea.cmdidx)) ? cmdnames[(int)ea.cmdidx].cmd_name : NULL);
|
||||||
|
|
||||||
undo_cmdmod(&ea, save_msg_scroll);
|
undo_cmdmod(save_msg_scroll);
|
||||||
cmdmod = save_cmdmod;
|
cmdmod = save_cmdmod;
|
||||||
reg_executing = save_reg_executing;
|
reg_executing = save_reg_executing;
|
||||||
pending_end_reg_executing = save_pending_end_reg_executing;
|
pending_end_reg_executing = save_pending_end_reg_executing;
|
||||||
|
|
||||||
if (ea.did_sandbox) {
|
|
||||||
sandbox--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ea.nextcmd && *ea.nextcmd == NUL) { // not really a next command
|
if (ea.nextcmd && *ea.nextcmd == NUL) { // not really a next command
|
||||||
ea.nextcmd = NULL;
|
ea.nextcmd = NULL;
|
||||||
}
|
}
|
||||||
@@ -2438,21 +2409,21 @@ char *ex_errmsg(const char *const msg, const char *const arg)
|
|||||||
/// - Set ex_pressedreturn for an empty command line.
|
/// - Set ex_pressedreturn for an empty command line.
|
||||||
/// - set msg_silent for ":silent"
|
/// - set msg_silent for ":silent"
|
||||||
/// - set 'eventignore' to "all" for ":noautocmd"
|
/// - set 'eventignore' to "all" for ":noautocmd"
|
||||||
/// - set p_verbose for ":verbose"
|
|
||||||
/// - Increment "sandbox" for ":sandbox"
|
|
||||||
///
|
///
|
||||||
/// @param skip_only if true, the global variables are not changed, except for
|
/// @param skip_only if true, the global variables are not changed, except for
|
||||||
/// "cmdmod".
|
/// "cmdmod".
|
||||||
/// @param[out] errormsg potential error message.
|
/// @param[out] errormsg potential error message.
|
||||||
///
|
///
|
||||||
|
/// Call apply_cmdmod() to get the side effects of the modifiers:
|
||||||
|
/// - Increment "sandbox" for ":sandbox"
|
||||||
|
/// - set p_verbose for ":verbose"
|
||||||
|
///
|
||||||
/// @return FAIL when the command is not to be executed.
|
/// @return FAIL when the command is not to be executed.
|
||||||
int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
memset(&cmdmod, 0, sizeof(cmdmod));
|
memset(&cmdmod, 0, sizeof(cmdmod));
|
||||||
eap->verbose_save = -1;
|
|
||||||
eap->save_msg_silent = -1;
|
|
||||||
|
|
||||||
// Repeat until no more command modifiers are found.
|
// Repeat until no more command modifiers are found.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -2590,12 +2561,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
if (checkforcmd(&eap->cmd, "noautocmd", 3)) {
|
if (checkforcmd(&eap->cmd, "noautocmd", 3)) {
|
||||||
if (cmdmod.save_ei == NULL && !skip_only) {
|
cmdmod.cmod_flags |= CMOD_NOAUTOCMD;
|
||||||
// Set 'eventignore' to "all". Restore the
|
|
||||||
// existing option value later.
|
|
||||||
cmdmod.save_ei = (char *)vim_strsave(p_ei);
|
|
||||||
set_string_option_direct("ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkforcmd(&eap->cmd, "noswapfile", 3)) {
|
if (!checkforcmd(&eap->cmd, "noswapfile", 3)) {
|
||||||
@@ -2613,30 +2579,17 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (checkforcmd(&eap->cmd, "sandbox", 3)) {
|
if (checkforcmd(&eap->cmd, "sandbox", 3)) {
|
||||||
if (!skip_only) {
|
cmdmod.cmod_flags |= CMOD_SANDBOX;
|
||||||
if (!eap->did_sandbox) {
|
|
||||||
sandbox++;
|
|
||||||
}
|
|
||||||
eap->did_sandbox = true;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkforcmd(&eap->cmd, "silent", 3)) {
|
if (!checkforcmd(&eap->cmd, "silent", 3)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!skip_only) {
|
cmdmod.cmod_flags |= CMOD_SILENT;
|
||||||
if (eap->save_msg_silent == -1) {
|
|
||||||
eap->save_msg_silent = msg_silent;
|
|
||||||
}
|
|
||||||
msg_silent++;
|
|
||||||
}
|
|
||||||
if (*eap->cmd == '!' && !ascii_iswhite(eap->cmd[-1])) {
|
if (*eap->cmd == '!' && !ascii_iswhite(eap->cmd[-1])) {
|
||||||
// ":silent!", but not "silent !cmd"
|
// ":silent!", but not "silent !cmd"
|
||||||
eap->cmd = skipwhite(eap->cmd + 1);
|
eap->cmd = skipwhite(eap->cmd + 1);
|
||||||
if (!skip_only) {
|
cmdmod.cmod_flags |= CMOD_ERRSILENT;
|
||||||
emsg_silent++;
|
|
||||||
eap->did_esilent++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -2669,12 +2622,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
if (!checkforcmd(&eap->cmd, "unsilent", 3)) {
|
if (!checkforcmd(&eap->cmd, "unsilent", 3)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!skip_only) {
|
cmdmod.cmod_flags |= CMOD_UNSILENT;
|
||||||
if (eap->save_msg_silent == -1) {
|
|
||||||
eap->save_msg_silent = msg_silent;
|
|
||||||
}
|
|
||||||
msg_silent = 0;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
@@ -2685,15 +2633,13 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
if (!checkforcmd(&p, "verbose", 4)) {
|
if (!checkforcmd(&p, "verbose", 4)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!skip_only) {
|
if (ascii_isdigit(*eap->cmd)) {
|
||||||
if (eap->verbose_save < 0) {
|
cmdmod.cmod_verbose = atoi((char *)eap->cmd);
|
||||||
eap->verbose_save = p_verbose;
|
if (cmdmod.cmod_verbose == 0) {
|
||||||
}
|
cmdmod.cmod_verbose = -1;
|
||||||
if (ascii_isdigit(*eap->cmd)) {
|
|
||||||
p_verbose = atoi(eap->cmd);
|
|
||||||
} else {
|
|
||||||
p_verbose = 1;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cmdmod.cmod_verbose = 1;
|
||||||
}
|
}
|
||||||
eap->cmd = p;
|
eap->cmd = p;
|
||||||
continue;
|
continue;
|
||||||
@@ -2704,29 +2650,75 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Undo and free contents of "cmdmod".
|
/// Apply the command modifiers. Saves current state in "cmdmod", call
|
||||||
static void undo_cmdmod(const exarg_T *eap, int save_msg_scroll)
|
/// undo_cmdmod() later.
|
||||||
FUNC_ATTR_NONNULL_ALL
|
static void apply_cmdmod(cmdmod_T *cmod)
|
||||||
{
|
{
|
||||||
if (eap->verbose_save >= 0) {
|
if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox) {
|
||||||
p_verbose = eap->verbose_save;
|
sandbox++;
|
||||||
|
cmod->cmod_did_sandbox = true;
|
||||||
|
}
|
||||||
|
if (cmod->cmod_verbose != 0) {
|
||||||
|
if (cmod->cmod_verbose_save == 0) {
|
||||||
|
cmod->cmod_verbose_save = p_verbose + 1;
|
||||||
|
}
|
||||||
|
p_verbose = cmod->cmod_verbose < 0 ? 0 : cmod->cmod_verbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdmod.save_ei != NULL) {
|
if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))
|
||||||
|
&& cmod->cmod_save_msg_silent == 0) {
|
||||||
|
cmod->cmod_save_msg_silent = msg_silent + 1;
|
||||||
|
}
|
||||||
|
if (cmod->cmod_flags & CMOD_SILENT) {
|
||||||
|
msg_silent++;
|
||||||
|
}
|
||||||
|
if (cmod->cmod_flags & CMOD_UNSILENT) {
|
||||||
|
msg_silent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmod->cmod_flags & CMOD_ERRSILENT) {
|
||||||
|
emsg_silent++;
|
||||||
|
cmod->cmod_did_esilent++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmdmod.cmod_save_ei == NULL) {
|
||||||
|
// Set 'eventignore' to "all".
|
||||||
|
// First save the existing option value for restoring it later.
|
||||||
|
cmdmod.cmod_save_ei = vim_strsave(p_ei);
|
||||||
|
set_string_option_direct("ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Undo and free contents of "cmdmod".
|
||||||
|
static void undo_cmdmod(int save_msg_scroll)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
if (cmdmod.cmod_verbose_save > 0) {
|
||||||
|
p_verbose = cmdmod.cmod_verbose_save - 1;
|
||||||
|
cmdmod.cmod_verbose_save = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdmod.cmod_did_sandbox) {
|
||||||
|
sandbox--;
|
||||||
|
cmdmod.cmod_did_sandbox = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdmod.cmod_save_ei != NULL) {
|
||||||
// Restore 'eventignore' to the value before ":noautocmd".
|
// Restore 'eventignore' to the value before ":noautocmd".
|
||||||
set_string_option_direct("ei", -1, (char_u *)cmdmod.save_ei, OPT_FREE, SID_NONE);
|
set_string_option_direct("ei", -1, (char_u *)cmdmod.cmod_save_ei, OPT_FREE, SID_NONE);
|
||||||
free_string_option((char_u *)cmdmod.save_ei);
|
free_string_option((char_u *)cmdmod.cmod_save_ei);
|
||||||
|
cmdmod.cmod_save_ei = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vim_regfree(cmdmod.filter_regmatch.regprog);
|
vim_regfree(cmdmod.filter_regmatch.regprog);
|
||||||
|
|
||||||
if (eap->save_msg_silent != -1) {
|
if (cmdmod.cmod_save_msg_silent > 0) {
|
||||||
// messages could be enabled for a serious error, need to check if the
|
// messages could be enabled for a serious error, need to check if the
|
||||||
// counters don't become negative
|
// counters don't become negative
|
||||||
if (!did_emsg || msg_silent > eap->save_msg_silent) {
|
if (!did_emsg || msg_silent > cmdmod.cmod_save_msg_silent - 1) {
|
||||||
msg_silent = eap->save_msg_silent;
|
msg_silent = cmdmod.cmod_save_msg_silent - 1;
|
||||||
}
|
}
|
||||||
emsg_silent -= eap->did_esilent;
|
emsg_silent -= cmdmod.cmod_did_esilent;
|
||||||
if (emsg_silent < 0) {
|
if (emsg_silent < 0) {
|
||||||
emsg_silent = 0;
|
emsg_silent = 0;
|
||||||
}
|
}
|
||||||
@@ -2739,6 +2731,9 @@ static void undo_cmdmod(const exarg_T *eap, int save_msg_scroll)
|
|||||||
if (redirecting()) {
|
if (redirecting()) {
|
||||||
msg_col = 0;
|
msg_col = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmdmod.cmod_save_msg_silent = 0;
|
||||||
|
cmdmod.cmod_did_esilent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1920,7 +1920,9 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
|
|||||||
lua_pushinteger(lstate, cmdmod.tab);
|
lua_pushinteger(lstate, cmdmod.tab);
|
||||||
lua_setfield(lstate, -2, "tab");
|
lua_setfield(lstate, -2, "tab");
|
||||||
|
|
||||||
lua_pushinteger(lstate, eap->verbose_save != -1 ? p_verbose : -1);
|
lua_pushinteger(lstate, (cmdmod.cmod_verbose != 0
|
||||||
|
? cmdmod.cmod_verbose < 0 ? 0 : cmdmod.cmod_verbose
|
||||||
|
: -1));
|
||||||
lua_setfield(lstate, -2, "verbose");
|
lua_setfield(lstate, -2, "verbose");
|
||||||
|
|
||||||
if (cmdmod.split & WSP_ABOVE) {
|
if (cmdmod.split & WSP_ABOVE) {
|
||||||
@@ -1938,13 +1940,13 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
|
|||||||
|
|
||||||
lua_pushboolean(lstate, cmdmod.split & WSP_VERT);
|
lua_pushboolean(lstate, cmdmod.split & WSP_VERT);
|
||||||
lua_setfield(lstate, -2, "vertical");
|
lua_setfield(lstate, -2, "vertical");
|
||||||
lua_pushboolean(lstate, eap->save_msg_silent != -1 ? (msg_silent != 0) : 0);
|
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_SILENT);
|
||||||
lua_setfield(lstate, -2, "silent");
|
lua_setfield(lstate, -2, "silent");
|
||||||
lua_pushboolean(lstate, eap->did_esilent);
|
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_ERRSILENT);
|
||||||
lua_setfield(lstate, -2, "emsg_silent");
|
lua_setfield(lstate, -2, "emsg_silent");
|
||||||
lua_pushboolean(lstate, eap->did_sandbox);
|
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_SANDBOX);
|
||||||
lua_setfield(lstate, -2, "sandbox");
|
lua_setfield(lstate, -2, "sandbox");
|
||||||
lua_pushboolean(lstate, cmdmod.save_ei != NULL);
|
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_NOAUTOCMD);
|
||||||
lua_setfield(lstate, -2, "noautocmd");
|
lua_setfield(lstate, -2, "noautocmd");
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Reference in New Issue
Block a user