mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 13:45:15 -07:00
vim-patch:8.2.5088: value of cmod_verbose is a bit complicated to use
Problem: Value of cmod_verbose is a bit complicated to use.
Solution: Use zero for not set, value + 1 when set. (closes vim/vim#10564)
cd7496382e
Omit has_cmdmod(): only used for Vim9 script
This commit is contained in:
parent
6130b4a84b
commit
0a0cda9528
@ -223,7 +223,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
|
||||
PUT(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX));
|
||||
PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOAUTOCMD));
|
||||
PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.cmod_tab));
|
||||
PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.verbose));
|
||||
PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.cmdmod.cmod_verbose - 1));
|
||||
PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_BROWSE));
|
||||
PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_CONFIRM));
|
||||
PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_HIDE));
|
||||
@ -287,7 +287,6 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
||||
|
||||
CmdParseInfo cmdinfo;
|
||||
memset(&cmdinfo, 0, sizeof(cmdinfo));
|
||||
cmdinfo.verbose = -1;
|
||||
|
||||
char *cmdline = NULL;
|
||||
char *cmdname = NULL;
|
||||
@ -524,7 +523,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
||||
VALIDATION_ERROR("'mods.verbose' must be a Integer");
|
||||
} else if ((int)mods.verbose.data.integer >= 0) {
|
||||
// Silently ignore negative integers to allow mods.verbose to be set to -1.
|
||||
cmdinfo.verbose = (int)mods.verbose.data.integer;
|
||||
cmdinfo.cmdmod.cmod_verbose = (int)mods.verbose.data.integer + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,8 +669,8 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
|
||||
if (cmdinfo->cmdmod.cmod_tab != 0) {
|
||||
kv_printf(cmdline, "%dtab ", cmdinfo->cmdmod.cmod_tab - 1);
|
||||
}
|
||||
if (cmdinfo->verbose != -1) {
|
||||
kv_printf(cmdline, "%dverbose ", cmdinfo->verbose);
|
||||
if (cmdinfo->cmdmod.cmod_verbose > 0) {
|
||||
kv_printf(cmdline, "%dverbose ", cmdinfo->cmdmod.cmod_verbose - 1);
|
||||
}
|
||||
|
||||
if (cmdinfo->cmdmod.cmod_flags & CMOD_ERRSILENT) {
|
||||
|
@ -264,28 +264,27 @@ enum {
|
||||
/// flag. This needs to be saved for recursive commands, put them in a
|
||||
/// structure for easy manipulation.
|
||||
typedef struct {
|
||||
int cmod_flags; ///< CMOD_ flags
|
||||
int cmod_flags; ///< CMOD_ flags
|
||||
|
||||
int cmod_split; ///< flags for win_split()
|
||||
int cmod_tab; ///< > 0 when ":tab" was used
|
||||
int cmod_split; ///< flags for win_split()
|
||||
int cmod_tab; ///< > 0 when ":tab" was used
|
||||
regmatch_T cmod_filter_regmatch; ///< set by :filter /pat/
|
||||
bool cmod_filter_force; ///< set for :filter!
|
||||
bool cmod_filter_force; ///< set for :filter!
|
||||
|
||||
int cmod_verbose; ///< non-zero to set 'verbose', -1 is used for zero override
|
||||
int cmod_verbose; ///< 0 if not set, > 0 to set 'verbose' to cmod_verbose - 1
|
||||
|
||||
// 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_save_msg_scroll; ///< for restoring msg_scroll
|
||||
int cmod_did_esilent; ///< incremented when emsg_silent is
|
||||
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_save_msg_scroll; ///< for restoring msg_scroll
|
||||
int cmod_did_esilent; ///< incremented when emsg_silent is
|
||||
} cmdmod_T;
|
||||
|
||||
/// Stores command modifier info used by `nvim_parse_cmd`
|
||||
typedef struct {
|
||||
cmdmod_T cmdmod;
|
||||
int verbose; ///< unlike cmod_verbose, -1 is used when unspecified and 0 for zero override
|
||||
struct {
|
||||
bool file;
|
||||
bool bar;
|
||||
|
@ -1430,12 +1430,6 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
|
||||
}
|
||||
after_modifier = eap->cmd;
|
||||
|
||||
if (cmdinfo->cmdmod.cmod_verbose != 0) {
|
||||
cmdinfo->verbose = cmdinfo->cmdmod.cmod_verbose < 0 ? 0 : cmdinfo->cmdmod.cmod_verbose;
|
||||
} else {
|
||||
cmdinfo->verbose = -1;
|
||||
}
|
||||
|
||||
// Save location after command modifiers
|
||||
cmd = eap->cmd;
|
||||
// Skip ranges to find command name since we need the command to know what kind of range it uses
|
||||
@ -1559,9 +1553,6 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
|
||||
cmdmod = cmdinfo->cmdmod;
|
||||
|
||||
// Apply command modifiers
|
||||
if (cmdinfo->verbose >= 0) {
|
||||
cmdmod.cmod_verbose = cmdinfo->verbose == 0 ? -1 : cmdinfo->verbose;
|
||||
}
|
||||
apply_cmdmod(&cmdmod);
|
||||
|
||||
if (!MODIFIABLE(curbuf) && (eap->argt & EX_MODIFY)
|
||||
@ -2614,12 +2605,10 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, cmdmod_T *cmod, bool
|
||||
break;
|
||||
}
|
||||
if (ascii_isdigit(*eap->cmd)) {
|
||||
cmod->cmod_verbose = atoi((char *)eap->cmd);
|
||||
if (cmod->cmod_verbose == 0) {
|
||||
cmod->cmod_verbose = -1;
|
||||
}
|
||||
// zero means not set, one is verbose == 0, etc.
|
||||
cmod->cmod_verbose = atoi((char *)eap->cmd) + 1;
|
||||
} else {
|
||||
cmod->cmod_verbose = 1;
|
||||
cmod->cmod_verbose = 2; // default: verbose == 1
|
||||
}
|
||||
eap->cmd = p;
|
||||
continue;
|
||||
@ -2638,11 +2627,11 @@ static void apply_cmdmod(cmdmod_T *cmod)
|
||||
sandbox++;
|
||||
cmod->cmod_did_sandbox = true;
|
||||
}
|
||||
if (cmod->cmod_verbose != 0) {
|
||||
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;
|
||||
p_verbose = cmod->cmod_verbose - 1;
|
||||
}
|
||||
|
||||
if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))
|
||||
|
@ -757,7 +757,7 @@ EXTERN bool did_cursorhold INIT(= false); // set when CursorHold t'gerd
|
||||
|
||||
EXTERN int postponed_split INIT(= 0); // for CTRL-W CTRL-] command
|
||||
EXTERN int postponed_split_flags INIT(= 0); // args for win_split()
|
||||
EXTERN int postponed_split_tab INIT(= 0); // cmdmod.tab
|
||||
EXTERN int postponed_split_tab INIT(= 0); // cmdmod.cmod_tab
|
||||
EXTERN int g_do_tagpreview INIT(= 0); // for tag preview commands:
|
||||
// height of preview window
|
||||
EXTERN bool g_tag_at_cursor INIT(= false); // whether the tag command comes
|
||||
|
@ -1920,9 +1920,7 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
|
||||
lua_pushinteger(lstate, cmdmod.cmod_tab);
|
||||
lua_setfield(lstate, -2, "tab");
|
||||
|
||||
lua_pushinteger(lstate, (cmdmod.cmod_verbose != 0
|
||||
? cmdmod.cmod_verbose < 0 ? 0 : cmdmod.cmod_verbose
|
||||
: -1));
|
||||
lua_pushinteger(lstate, cmdmod.cmod_verbose - 1);
|
||||
lua_setfield(lstate, -2, "verbose");
|
||||
|
||||
if (cmdmod.cmod_split & WSP_ABOVE) {
|
||||
|
Loading…
Reference in New Issue
Block a user