aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-06-14 20:46:18 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-06-14 21:12:27 +0800
commit0a0cda95286bf62fbce2776a0c0081cea39a88a8 (patch)
tree03f43740a5822d058abf8822e9bfe8b561d460be
parent6130b4a84b41b71f4c0c58093a29585c6c67ff16 (diff)
downloadrneovim-0a0cda95286bf62fbce2776a0c0081cea39a88a8.tar.gz
rneovim-0a0cda95286bf62fbce2776a0c0081cea39a88a8.tar.bz2
rneovim-0a0cda95286bf62fbce2776a0c0081cea39a88a8.zip
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) https://github.com/vim/vim/commit/cd7496382efc9e6748326c6cda7f01003fa07063 Omit has_cmdmod(): only used for Vim9 script
-rw-r--r--src/nvim/api/command.c9
-rw-r--r--src/nvim/ex_cmds_defs.h23
-rw-r--r--src/nvim/ex_docmd.c21
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/lua/executor.c4
5 files changed, 22 insertions, 37 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index f48843cbbb..0d2e013aac 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -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) {
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index ab6f448c66..8280f99547 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -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;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 7ccbaaa4cb..28b1a7580d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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))
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index a42c8e979d..7830e9caea 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -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
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 5bc06bf3fe..b0054be613 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -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) {