aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-06-14 21:57:08 +0800
committerGitHub <noreply@github.com>2022-06-14 21:57:08 +0800
commit8ba64dd3ad1822efd6f986349e99f5f85afd7be7 (patch)
tree66b2987707cf6616614fb251d7e342ccdfd96c28 /src
parent2a2fb8be74f9147773416be63334ea6a74c66869 (diff)
parent0a0cda95286bf62fbce2776a0c0081cea39a88a8 (diff)
downloadrneovim-8ba64dd3ad1822efd6f986349e99f5f85afd7be7.tar.gz
rneovim-8ba64dd3ad1822efd6f986349e99f5f85afd7be7.tar.bz2
rneovim-8ba64dd3ad1822efd6f986349e99f5f85afd7be7.zip
Merge pull request #18947 from zeertzjq/vim-8.2.1897
vim-patch:8.2.{1897,1898,5088}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/command.c140
-rw-r--r--src/nvim/buffer.c22
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/diff.c10
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/ex_cmds.c56
-rw-r--r--src/nvim/ex_cmds2.c8
-rw-r--r--src/nvim/ex_cmds_defs.h56
-rw-r--r--src/nvim/ex_docmd.c325
-rw-r--r--src/nvim/ex_getln.c17
-rw-r--r--src/nvim/fileio.c6
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/if_cscope.c4
-rw-r--r--src/nvim/lua/executor.c44
-rw-r--r--src/nvim/mark.c10
-rw-r--r--src/nvim/memline.c7
-rw-r--r--src/nvim/message.c6
-rw-r--r--src/nvim/ops.c28
-rw-r--r--src/nvim/option.c2
-rw-r--r--src/nvim/quickfix.c16
-rw-r--r--src/nvim/search.c4
-rw-r--r--src/nvim/tag.c2
-rw-r--r--src/nvim/window.c10
23 files changed, 382 insertions, 397 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index a7115c09a3..0d2e013aac 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -218,31 +218,31 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
PUT(result, "nextcmd", CSTR_TO_OBJ((char *)ea.nextcmd));
Dictionary mods = ARRAY_DICT_INIT;
- PUT(mods, "silent", BOOLEAN_OBJ(cmdinfo.silent));
- PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.emsg_silent));
- PUT(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.sandbox));
- PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.noautocmd));
- PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.tab));
- PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.verbose));
- PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.browse));
- PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.confirm));
- PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.hide));
- PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.keepalt));
- PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.keepjumps));
- PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.keepmarks));
- PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.keeppatterns));
- PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.lockmarks));
- PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.noswapfile));
- PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.split & WSP_VERT));
+ PUT(mods, "silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SILENT));
+ PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_ERRSILENT));
+ 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.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));
+ PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPALT));
+ PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPJUMPS));
+ PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPMARKS));
+ PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPPATTERNS));
+ PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_LOCKMARKS));
+ PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOSWAPFILE));
+ PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_split & WSP_VERT));
const char *split;
- if (cmdinfo.cmdmod.split & WSP_BOT) {
+ if (cmdinfo.cmdmod.cmod_split & WSP_BOT) {
split = "botright";
- } else if (cmdinfo.cmdmod.split & WSP_TOP) {
+ } else if (cmdinfo.cmdmod.cmod_split & WSP_TOP) {
split = "topleft";
- } else if (cmdinfo.cmdmod.split & WSP_BELOW) {
+ } else if (cmdinfo.cmdmod.cmod_split & WSP_BELOW) {
split = "belowright";
- } else if (cmdinfo.cmdmod.split & WSP_ABOVE) {
+ } else if (cmdinfo.cmdmod.cmod_split & WSP_ABOVE) {
split = "aboveleft";
} else {
split = "";
@@ -284,12 +284,9 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
{
exarg_T ea;
memset(&ea, 0, sizeof(ea));
- ea.verbose_save = -1;
- ea.save_msg_silent = -1;
CmdParseInfo cmdinfo;
memset(&cmdinfo, 0, sizeof(cmdinfo));
- cmdinfo.verbose = -1;
char *cmdline = NULL;
char *cmdname = NULL;
@@ -300,7 +297,17 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
#define OBJ_TO_BOOL(var, value, default, varname) \
do { \
- var = api_object_to_bool(value, varname, default, err); \
+ (var) = api_object_to_bool(value, varname, default, err); \
+ if (ERROR_SET(err)) { \
+ goto end; \
+ } \
+ } while (0)
+
+#define OBJ_TO_CMOD_FLAG(flag, value, default, varname) \
+ do { \
+ if (api_object_to_bool(value, varname, default, err)) { \
+ cmdinfo.cmdmod.cmod_flags |= (flag); \
+ } \
if (ERROR_SET(err)) { \
goto end; \
} \
@@ -508,21 +515,21 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
if (mods.tab.type != kObjectTypeInteger || mods.tab.data.integer < 0) {
VALIDATION_ERROR("'mods.tab' must be a non-negative Integer");
}
- cmdinfo.cmdmod.tab = (int)mods.tab.data.integer + 1;
+ cmdinfo.cmdmod.cmod_tab = (int)mods.tab.data.integer + 1;
}
if (HAS_KEY(mods.verbose)) {
if (mods.verbose.type != kObjectTypeInteger) {
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.
- cmdinfo.verbose = mods.verbose.data.integer;
+ cmdinfo.cmdmod.cmod_verbose = (int)mods.verbose.data.integer + 1;
}
}
bool vertical;
OBJ_TO_BOOL(vertical, mods.vertical, false, "'mods.vertical'");
- cmdinfo.cmdmod.split |= (vertical ? WSP_VERT : 0);
+ cmdinfo.cmdmod.cmod_split |= (vertical ? WSP_VERT : 0);
if (HAS_KEY(mods.split)) {
if (mods.split.type != kObjectTypeString) {
@@ -533,34 +540,34 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
// Empty string, do nothing.
} else if (STRCMP(mods.split.data.string.data, "aboveleft") == 0
|| STRCMP(mods.split.data.string.data, "leftabove") == 0) {
- cmdinfo.cmdmod.split |= WSP_ABOVE;
+ cmdinfo.cmdmod.cmod_split |= WSP_ABOVE;
} else if (STRCMP(mods.split.data.string.data, "belowright") == 0
|| STRCMP(mods.split.data.string.data, "rightbelow") == 0) {
- cmdinfo.cmdmod.split |= WSP_BELOW;
+ cmdinfo.cmdmod.cmod_split |= WSP_BELOW;
} else if (STRCMP(mods.split.data.string.data, "topleft") == 0) {
- cmdinfo.cmdmod.split |= WSP_TOP;
+ cmdinfo.cmdmod.cmod_split |= WSP_TOP;
} else if (STRCMP(mods.split.data.string.data, "botright") == 0) {
- cmdinfo.cmdmod.split |= WSP_BOT;
+ cmdinfo.cmdmod.cmod_split |= WSP_BOT;
} else {
VALIDATION_ERROR("Invalid value for 'mods.split'");
}
}
- OBJ_TO_BOOL(cmdinfo.silent, mods.silent, false, "'mods.silent'");
- OBJ_TO_BOOL(cmdinfo.emsg_silent, mods.emsg_silent, false, "'mods.emsg_silent'");
- OBJ_TO_BOOL(cmdinfo.sandbox, mods.sandbox, false, "'mods.sandbox'");
- OBJ_TO_BOOL(cmdinfo.noautocmd, mods.noautocmd, false, "'mods.noautocmd'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.browse, mods.browse, false, "'mods.browse'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.confirm, mods.confirm, false, "'mods.confirm'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.hide, mods.hide, false, "'mods.hide'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.keepalt, mods.keepalt, false, "'mods.keepalt'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.keepjumps, mods.keepjumps, false, "'mods.keepjumps'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.keepmarks, mods.keepmarks, false, "'mods.keepmarks'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.keeppatterns, mods.keeppatterns, false, "'mods.keeppatterns'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.lockmarks, mods.lockmarks, false, "'mods.lockmarks'");
- OBJ_TO_BOOL(cmdinfo.cmdmod.noswapfile, mods.noswapfile, false, "'mods.noswapfile'");
-
- if (cmdinfo.sandbox && !(ea.argt & EX_SBOXOK)) {
+ OBJ_TO_CMOD_FLAG(CMOD_SILENT, mods.silent, false, "'mods.silent'");
+ OBJ_TO_CMOD_FLAG(CMOD_ERRSILENT, mods.emsg_silent, false, "'mods.emsg_silent'");
+ OBJ_TO_CMOD_FLAG(CMOD_SANDBOX, mods.sandbox, false, "'mods.sandbox'");
+ OBJ_TO_CMOD_FLAG(CMOD_NOAUTOCMD, mods.noautocmd, false, "'mods.noautocmd'");
+ OBJ_TO_CMOD_FLAG(CMOD_BROWSE, mods.browse, false, "'mods.browse'");
+ OBJ_TO_CMOD_FLAG(CMOD_CONFIRM, mods.confirm, false, "'mods.confirm'");
+ OBJ_TO_CMOD_FLAG(CMOD_HIDE, mods.hide, false, "'mods.hide'");
+ OBJ_TO_CMOD_FLAG(CMOD_KEEPALT, mods.keepalt, false, "'mods.keepalt'");
+ OBJ_TO_CMOD_FLAG(CMOD_KEEPJUMPS, mods.keepjumps, false, "'mods.keepjumps'");
+ OBJ_TO_CMOD_FLAG(CMOD_KEEPMARKS, mods.keepmarks, false, "'mods.keepmarks'");
+ OBJ_TO_CMOD_FLAG(CMOD_KEEPPATTERNS, mods.keeppatterns, false, "'mods.keeppatterns'");
+ OBJ_TO_CMOD_FLAG(CMOD_LOCKMARKS, mods.lockmarks, false, "'mods.lockmarks'");
+ OBJ_TO_CMOD_FLAG(CMOD_NOSWAPFILE, mods.noswapfile, false, "'mods.noswapfile'");
+
+ if ((cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX) && !(ea.argt & EX_SBOXOK)) {
VALIDATION_ERROR("Command cannot be run in sandbox");
}
}
@@ -631,6 +638,7 @@ end:
return retv;
#undef OBJ_TO_BOOL
+#undef OBJ_TO_CMOD_FLAG
#undef VALIDATION_ERROR
}
@@ -658,20 +666,20 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
StringBuilder cmdline = KV_INITIAL_VALUE;
// Add command modifiers
- if (cmdinfo->cmdmod.tab != 0) {
- kv_printf(cmdline, "%dtab ", cmdinfo->cmdmod.tab - 1);
+ if (cmdinfo->cmdmod.cmod_tab != 0) {
+ kv_printf(cmdline, "%dtab ", cmdinfo->cmdmod.cmod_tab - 1);
}
- if (cmdinfo->verbose != -1) {
- kv_printf(cmdline, "%ldverbose ", cmdinfo->verbose);
+ if (cmdinfo->cmdmod.cmod_verbose > 0) {
+ kv_printf(cmdline, "%dverbose ", cmdinfo->cmdmod.cmod_verbose - 1);
}
- if (cmdinfo->emsg_silent) {
+ if (cmdinfo->cmdmod.cmod_flags & CMOD_ERRSILENT) {
kv_concat(cmdline, "silent! ");
- } else if (cmdinfo->silent) {
+ } else if (cmdinfo->cmdmod.cmod_flags & CMOD_SILENT) {
kv_concat(cmdline, "silent ");
}
- switch (cmdinfo->cmdmod.split & (WSP_ABOVE | WSP_BELOW | WSP_TOP | WSP_BOT)) {
+ switch (cmdinfo->cmdmod.cmod_split & (WSP_ABOVE | WSP_BELOW | WSP_TOP | WSP_BOT)) {
case WSP_ABOVE:
kv_concat(cmdline, "aboveleft ");
break;
@@ -695,18 +703,18 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
} \
} while (0)
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.split & WSP_VERT, "vertical ");
- CMDLINE_APPEND_IF(cmdinfo->sandbox, "sandbox ");
- CMDLINE_APPEND_IF(cmdinfo->noautocmd, "noautocmd ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.browse, "browse ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.confirm, "confirm ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.hide, "hide ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.keepalt, "keepalt ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.keepjumps, "keepjumps ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.keepmarks, "keepmarks ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.keeppatterns, "keeppatterns ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.lockmarks, "lockmarks ");
- CMDLINE_APPEND_IF(cmdinfo->cmdmod.noswapfile, "noswapfile ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_split & WSP_VERT, "vertical ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_SANDBOX, "sandbox ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_NOAUTOCMD, "noautocmd ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_BROWSE, "browse ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_CONFIRM, "confirm ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_HIDE, "hide ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPALT, "keepalt ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPJUMPS, "keepjumps ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPMARKS, "keepmarks ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPPATTERNS, "keeppatterns ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_LOCKMARKS, "lockmarks ");
+ CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_NOSWAPFILE, "noswapfile ");
#undef CMDLINE_APPEND_IF
// Command range / count.
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 921cd20943..4fb3f66349 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1191,7 +1191,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
}
if (!forceit && bufIsChanged(buf)) {
- if ((p_confirm || cmdmod.confirm) && p_write) {
+ if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) {
dialog_changed(buf, false);
if (!bufref_valid(&bufref)) {
// Autocommand deleted buffer, oops! It's not changed now.
@@ -1211,7 +1211,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
}
if (!forceit && buf->terminal && terminal_running(buf->terminal)) {
- if (p_confirm || cmdmod.confirm) {
+ if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
if (!dialog_close_terminal(buf)) {
return FAIL;
}
@@ -1393,7 +1393,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
// Check if the current buffer may be abandoned.
if (action == DOBUF_GOTO && !can_abandon(curbuf, forceit)) {
- if ((p_confirm || cmdmod.confirm) && p_write) {
+ if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) {
bufref_T bufref;
set_bufref(&bufref, buf);
dialog_changed(curbuf, false);
@@ -1439,7 +1439,7 @@ void set_curbuf(buf_T *buf, int action)
long old_tw = curbuf->b_p_tw;
setpcmark();
- if (!cmdmod.keepalt) {
+ if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file
}
buflist_altfpos(curwin); // remember curpos
@@ -2846,7 +2846,7 @@ buf_T *setaltfname(char_u *ffname, char_u *sfname, linenr_T lnum)
// Create a buffer. 'buflisted' is not set if it's a new buffer
buf = buflist_new(ffname, sfname, lnum, 0);
- if (buf != NULL && !cmdmod.keepalt) {
+ if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = buf->b_fnum;
}
return buf;
@@ -4659,7 +4659,7 @@ void do_arg_all(int count, int forceit, int keep_tabs)
alist_T *alist; // argument list to be used
buf_T *buf;
tabpage_T *tpnext;
- int had_tab = cmdmod.tab;
+ int had_tab = cmdmod.cmod_tab;
win_T *old_curwin, *last_curwin;
tabpage_T *old_curtab, *last_curtab;
win_T *new_curwin = NULL;
@@ -4870,7 +4870,7 @@ void do_arg_all(int count, int forceit, int keep_tabs)
// When ":tab" was used open a new tab for a new window repeatedly.
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) {
- cmdmod.tab = 9999;
+ cmdmod.cmod_tab = 9999;
}
}
@@ -4917,7 +4917,7 @@ void ex_buffer_all(exarg_T *eap)
int r;
long count; // Maximum number of windows to open.
int all; // When true also load inactive buffers.
- int had_tab = cmdmod.tab;
+ int had_tab = cmdmod.cmod_tab;
tabpage_T *tpnext;
if (eap->addr_count == 0) { // make as many windows as possible
@@ -4943,7 +4943,7 @@ void ex_buffer_all(exarg_T *eap)
for (wp = firstwin; wp != NULL; wp = wpnext) {
wpnext = wp->w_next;
if ((wp->w_buffer->b_nwindows > 1
- || ((cmdmod.split & WSP_VERT)
+ || ((cmdmod.cmod_split & WSP_VERT)
? wp->w_height + wp->w_hsep_height + wp->w_status_height < Rows - p_ch
- tabline_height() - global_stl_height()
: wp->w_width != Columns)
@@ -5056,7 +5056,7 @@ void ex_buffer_all(exarg_T *eap)
}
// When ":tab" was used open a new tab for a new window repeatedly.
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) {
- cmdmod.tab = 9999;
+ cmdmod.cmod_tab = 9999;
}
}
autocmd_no_enter--;
@@ -5322,7 +5322,7 @@ bool buf_hide(const buf_T *const buf)
case 'h':
return true; // "hide"
}
- return p_hid || cmdmod.hide;
+ return p_hid || (cmdmod.cmod_flags & CMOD_HIDE);
}
/// @return special buffer name or
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 21afbf66de..c0796386f1 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -148,7 +148,7 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, linenr_T
}
// set the '. mark
- if (!cmdmod.keepjumps) {
+ if ((cmdmod.cmod_flags & CMOD_KEEPJUMPS) == 0) {
RESET_FMARK(&curbuf->b_last_change, ((pos_T) { lnum, col, 0 }), 0);
// Create a new entry if a new undo-able change was started or we
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index a622100918..700e79ac75 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -790,14 +790,14 @@ static int diff_write(buf_T *buf, diffin_T *din)
// Always use 'fileformat' set to "unix".
char_u *save_ff = buf->b_p_ff;
buf->b_p_ff = vim_strsave((char_u *)FF_UNIX);
- const bool save_lockmarks = cmdmod.lockmarks;
+ const bool save_cmod_flags = cmdmod.cmod_flags;
// Writing the buffer is an implementation detail of performing the diff,
// so it shouldn't update the '[ and '] marks.
- cmdmod.lockmarks = true;
+ cmdmod.cmod_flags |= CMOD_LOCKMARKS;
int r = buf_write(buf, (char *)din->din_fname, NULL,
(linenr_T)1, buf->b_ml.ml_line_count,
NULL, false, false, false, true);
- cmdmod.lockmarks = save_lockmarks;
+ cmdmod.cmod_flags = save_cmod_flags;
free_string_option(buf->b_p_ff);
buf->b_p_ff = save_ff;
return r;
@@ -1263,7 +1263,7 @@ void ex_diffpatch(exarg_T *eap)
}
// don't use a new tab page, each tab page has its own diffs
- cmdmod.tab = 0;
+ cmdmod.cmod_tab = 0;
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
// Pretend it was a ":split fname" command
@@ -1323,7 +1323,7 @@ void ex_diffsplit(exarg_T *eap)
set_fraction(curwin);
// don't use a new tab page, each tab page has its own diffs
- cmdmod.tab = 0;
+ cmdmod.cmod_tab = 0;
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
// Pretend it was a ":split fname" command
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 7bdce3eadd..8f7ba03b14 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -7956,7 +7956,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove)
}
// Remember the last Insert position in the '^ mark.
- if (!cmdmod.keepjumps) {
+ if ((cmdmod.cmod_flags & CMOD_KEEPJUMPS) == 0) {
RESET_FMARK(&curbuf->b_last_insert, curwin->w_cursor, curbuf->b_fnum);
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 9bb77ce928..73e6e4a62f 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -981,7 +981,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
foldMoveRange(win, &win->w_folds, line1, line2, dest);
}
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
curbuf->b_op_start.lnum = dest - num_lines + 1;
curbuf->b_op_end.lnum = dest;
}
@@ -994,12 +994,12 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
foldMoveRange(win, &win->w_folds, dest + 1, line1 - 1, line2);
}
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
curbuf->b_op_start.lnum = dest + 1;
curbuf->b_op_end.lnum = dest + num_lines;
}
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
}
mark_adjust_nofold(last_line - num_lines + 1, last_line,
@@ -1064,7 +1064,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
char *p;
count = line2 - line1 + 1;
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
curbuf->b_op_start.lnum = n + 1;
curbuf->b_op_end.lnum = n + count;
curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
@@ -1287,10 +1287,10 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b
return;
}
- const bool save_lockmarks = cmdmod.lockmarks;
+ const int save_cmod_flags = cmdmod.cmod_flags;
// Temporarily disable lockmarks since that's needed to propagate changed
// regions of the buffer for foldUpdate(), linecount, etc.
- cmdmod.lockmarks = false;
+ cmdmod.cmod_flags &= ~CMOD_LOCKMARKS;
cursor_save = curwin->w_cursor;
linecount = line2 - line1 + 1;
@@ -1410,7 +1410,8 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char *cmd, b
}
if (do_in) {
- if (cmdmod.keepmarks || vim_strchr(p_cpo, CPO_REMMARK) == NULL) {
+ if ((cmdmod.cmod_flags & CMOD_KEEPMARKS)
+ || vim_strchr(p_cpo, CPO_REMMARK) == NULL) {
// TODO(bfredl): Currently not active for extmarks. What would we
// do if columns don't match, assume added/deleted bytes at the
// end of each line?
@@ -1471,11 +1472,11 @@ error:
filterend:
- cmdmod.lockmarks = save_lockmarks;
+ cmdmod.cmod_flags = save_cmod_flags;
if (curbuf != old_curbuf) {
no_wait_return--;
emsg(_("E135: *Filter* Autocommands must not change current buffer"));
- } else if (cmdmod.lockmarks) {
+ } else if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
curbuf->b_op_start = orig_start;
curbuf->b_op_end = orig_end;
}
@@ -1730,7 +1731,7 @@ int rename_buffer(char *new_fname)
curbuf->b_flags |= BF_NOTEDITED;
if (xfname != NULL && *xfname != NUL) {
buf = buflist_new((char_u *)fname, (char_u *)xfname, curwin->w_cursor.lnum, 0);
- if (buf != NULL && !cmdmod.keepalt) {
+ if (buf != NULL && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = buf->b_fnum;
}
}
@@ -1866,7 +1867,7 @@ int do_write(exarg_T *eap)
&& !eap->forceit
&& !eap->append
&& !p_wa) {
- if (p_confirm || cmdmod.confirm) {
+ if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
if (vim_dialog_yesno(VIM_QUESTION, NULL,
(char_u *)_("Write partial file?"), 2) != VIM_YES) {
goto theend;
@@ -1985,7 +1986,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
return FAIL;
}
#endif
- if (p_confirm || cmdmod.confirm) {
+ if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
char buff[DIALOG_MSG_SIZE];
dialog_msg((char *)buff, _("Overwrite existing file \"%s\"?"), fname);
@@ -2021,7 +2022,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
swapname = (char *)makeswapname((char_u *)fname, (char_u *)ffname, curbuf, (char_u *)dir);
xfree(dir);
if (os_path_exists((char_u *)swapname)) {
- if (p_confirm || cmdmod.confirm) {
+ if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
char buff[DIALOG_MSG_SIZE];
dialog_msg((char *)buff,
@@ -2142,7 +2143,7 @@ static int check_readonly(int *forceit, buf_T *buf)
if (!*forceit && (buf->b_p_ro
|| (os_path_exists(buf->b_ffname)
&& !os_file_is_writable((char *)buf->b_ffname)))) {
- if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL) {
+ if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && buf->b_fname != NULL) {
char buff[DIALOG_MSG_SIZE];
if (buf->b_p_ro) {
@@ -2401,7 +2402,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
*/
if (other_file) {
if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF))) {
- if (!cmdmod.keepalt) {
+ if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = curbuf->b_fnum;
}
if (oldwin != NULL) {
@@ -3028,7 +3029,7 @@ void ex_append(exarg_T *eap)
// eap->line2 pointed to the end of the buffer and nothing was appended)
// "end" is set to lnum when something has been appended, otherwise
// it is the same as "start" -- Acevedo
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
curbuf->b_op_start.lnum
= (eap->line2 < curbuf->b_ml.ml_line_count) ? eap->line2 + 1 : curbuf->b_ml.ml_line_count;
if (eap->cmdidx != CMD_append) {
@@ -3307,7 +3308,7 @@ static bool sub_joining_lines(exarg_T *eap, char *pat, char *sub, char *cmd, boo
}
if (save) {
- if (!cmdmod.keeppatterns) {
+ if ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0) {
save_re_pat(RE_SUBST, (char_u *)pat, p_magic);
}
add_to_history(HIST_SEARCH, (char_u *)pat, true, NUL);
@@ -4373,7 +4374,7 @@ skip:
}
if (sub_nsubs > start_nsubs) {
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set the '[ and '] marks.
curbuf->b_op_start.lnum = eap->line1;
curbuf->b_op_end.lnum = line2;
@@ -4826,8 +4827,8 @@ void ex_help(exarg_T *eap)
* Always open a new one for ":tab help".
*/
if (!bt_help(curwin->w_buffer)
- || cmdmod.tab != 0) {
- if (cmdmod.tab != 0) {
+ || cmdmod.cmod_tab != 0) {
+ if (cmdmod.cmod_tab != 0) {
wp = NULL;
} else {
wp = NULL;
@@ -4853,7 +4854,7 @@ void ex_help(exarg_T *eap)
// specified, the current window is vertically split and
// narrow.
n = WSP_HELP;
- if (cmdmod.split == 0 && curwin->w_width != Columns
+ if (cmdmod.cmod_split == 0 && curwin->w_width != Columns
&& curwin->w_width < 80) {
n |= WSP_TOP;
}
@@ -4873,9 +4874,9 @@ void ex_help(exarg_T *eap)
alt_fnum = curbuf->b_fnum;
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
ECMD_HIDE + ECMD_SET_HELP,
- NULL // buffer is still open, don't store info
- );
- if (!cmdmod.keepalt) {
+ NULL); // buffer is still open, don't store info
+
+ if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = alt_fnum;
}
empty_fnum = curbuf->b_fnum;
@@ -4901,7 +4902,8 @@ void ex_help(exarg_T *eap)
}
// keep the previous alternate file
- if (alt_fnum != 0 && curwin->w_alt_fnum == empty_fnum && !cmdmod.keepalt) {
+ if (alt_fnum != 0 && curwin->w_alt_fnum == empty_fnum
+ && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
curwin->w_alt_fnum = alt_fnum;
}
@@ -6069,7 +6071,7 @@ void ex_oldfiles(exarg_T *eap)
got_int = false;
// File selection prompt on ":browse oldfiles"
- if (cmdmod.browse) {
+ if (cmdmod.cmod_flags & CMOD_BROWSE) {
quit_more = false;
nr = prompt_for_number(false);
msg_starthere();
@@ -6081,7 +6083,7 @@ void ex_oldfiles(exarg_T *eap)
char *const s = expand_env_save((char *)p);
eap->arg = s;
eap->cmdidx = CMD_edit;
- cmdmod.browse = false;
+ cmdmod.cmod_flags &= ~CMOD_BROWSE;
do_exedit(eap, NULL);
xfree(s);
}
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index d4555f9917..9b260f9091 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -506,7 +506,7 @@ bool check_changed(buf_T *buf, int flags)
&& bufIsChanged(buf)
&& ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1)
&& (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL)) {
- if ((p_confirm || cmdmod.confirm) && p_write) {
+ if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) {
int count = 0;
if (flags & CCGD_ALLBUF) {
@@ -719,7 +719,7 @@ bool check_changed_any(bool hidden, bool unload)
ret = true;
exiting = false;
// When ":confirm" used, don't give an error message.
- if (!(p_confirm || cmdmod.confirm)) {
+ if (!(p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))) {
// There must be a wait_return for this message, do_buffer()
// may cause a redraw. But wait_return() is a no-op when vgetc()
// is busy (Quit used from window menu), then make sure we don't
@@ -1127,7 +1127,7 @@ void do_argfile(exarg_T *eap, int argn)
setpcmark();
// split window or create new tab page first
- if (*eap->cmd == 's' || cmdmod.tab != 0) {
+ if (*eap->cmd == 's' || cmdmod.cmod_tab != 0) {
if (win_split(0, 0) == FAIL) {
return;
}
@@ -3027,7 +3027,7 @@ void ex_drop(exarg_T *eap)
return;
}
- if (cmdmod.tab) {
+ if (cmdmod.cmod_tab) {
// ":tab drop file ...": open a tab for each argument that isn't
// edited in a window yet. It's like ":tab all" but without closing
// windows or tabs.
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index a5c9c6be2d..8280f99547 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -209,10 +209,6 @@ struct exarg {
LineGetter getline; ///< Function used to get the next line
void *cookie; ///< argument for getline()
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"
@@ -247,33 +243,47 @@ struct expand {
#define XP_BS_ONE 1 // uses one backslash before a space
#define XP_BS_THREE 2 // uses three backslashes before a space
+enum {
+ CMOD_SANDBOX = 0x0001, ///< ":sandbox"
+ CMOD_SILENT = 0x0002, ///< ":silent"
+ CMOD_ERRSILENT = 0x0004, ///< ":silent!"
+ CMOD_UNSILENT = 0x0008, ///< ":unsilent"
+ CMOD_NOAUTOCMD = 0x0010, ///< ":noautocmd"
+ CMOD_HIDE = 0x0020, ///< ":hide"
+ CMOD_BROWSE = 0x0040, ///< ":browse" - invoke file dialog
+ CMOD_CONFIRM = 0x0080, ///< ":confirm" - invoke yes/no dialog
+ CMOD_KEEPALT = 0x0100, ///< ":keepalt"
+ CMOD_KEEPMARKS = 0x0200, ///< ":keepmarks"
+ CMOD_KEEPJUMPS = 0x0400, ///< ":keepjumps"
+ CMOD_LOCKMARKS = 0x0800, ///< ":lockmarks"
+ CMOD_KEEPPATTERNS = 0x1000, ///< ":keeppatterns"
+ CMOD_NOSWAPFILE = 0x2000, ///< ":noswapfile"
+};
+
/// Command modifiers ":vertical", ":browse", ":confirm", ":hide", etc. set a
/// flag. This needs to be saved for recursive commands, put them in a
/// structure for easy manipulation.
typedef struct {
- int split; ///< flags for win_split()
- int tab; ///< > 0 when ":tab" was used
- bool browse; ///< true to invoke file dialog
- bool confirm; ///< true to invoke yes/no dialog
- bool hide; ///< true when ":hide" was used
- bool keepalt; ///< true when ":keepalt" was used
- bool keepjumps; ///< true when ":keepjumps" was used
- bool keepmarks; ///< true when ":keepmarks" was used
- bool keeppatterns; ///< true when ":keeppatterns" was used
- bool lockmarks; ///< true when ":lockmarks" was used
- bool noswapfile; ///< true when ":noswapfile" was used
- char *save_ei; ///< saved value of 'eventignore'
- regmatch_T filter_regmatch; ///< set by :filter /pat/
- bool filter_force; ///< set for :filter!
+ int cmod_flags; ///< CMOD_ flags
+
+ 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!
+
+ 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
} cmdmod_T;
/// Stores command modifier info used by `nvim_parse_cmd`
typedef struct {
- bool silent;
- bool emsg_silent;
- bool sandbox;
- bool noautocmd;
- long verbose;
cmdmod_T cmdmod;
struct {
bool file;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index bbac74fc55..28b1a7580d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1411,7 +1411,6 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
char *cmd;
char *p;
char *after_modifier = NULL;
- cmdmod_T save_cmdmod = cmdmod;
// Initialize cmdinfo
memset(cmdinfo, 0, sizeof(*cmdinfo));
@@ -1426,42 +1425,11 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
eap->cookie = NULL;
// Parse command modifiers
- if (parse_command_modifiers(eap, errormsg, false) == FAIL) {
+ if (parse_command_modifiers(eap, errormsg, &cmdinfo->cmdmod, false) == FAIL) {
return false;
}
after_modifier = eap->cmd;
- // Revert the side-effects of `parse_command_modifiers`
- if (eap->save_msg_silent != -1) {
- cmdinfo->silent = !!msg_silent;
- msg_silent = eap->save_msg_silent;
- eap->save_msg_silent = -1;
- }
- 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 {
- cmdinfo->verbose = -1;
- }
- cmdinfo->cmdmod = cmdmod;
- cmdmod = save_cmdmod;
-
// 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
@@ -1585,26 +1553,7 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
cmdmod = cmdinfo->cmdmod;
// Apply command modifiers
- if (cmdinfo->silent) {
- eap->save_msg_silent = msg_silent;
- msg_silent++;
- }
- if (cmdinfo->emsg_silent) {
- eap->did_esilent = true;
- emsg_silent++;
- }
- if (cmdinfo->sandbox) {
- eap->did_sandbox = true;
- sandbox++;
- }
- if (cmdinfo->noautocmd) {
- cmdmod.save_ei = (char *)vim_strsave(p_ei);
- set_string_option_direct("ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
- }
- if (cmdinfo->verbose != -1) {
- eap->verbose_save = p_verbose;
- p_verbose = cmdinfo->verbose;
- }
+ apply_cmdmod(&cmdmod);
if (!MODIFIABLE(curbuf) && (eap->argt & EX_MODIFY)
// allow :put in terminals
@@ -1712,11 +1661,8 @@ end:
emsg(errormsg);
}
// Undo command modifiers
- undo_cmdmod(eap, msg_scroll);
+ undo_cmdmod(&cmdmod);
cmdmod = save_cmdmod;
- if (eap->did_sandbox) {
- sandbox--;
- }
return retv;
#undef ERROR
}
@@ -1746,7 +1692,6 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
char *errormsg = NULL; // error message
char *after_modifier = NULL;
exarg_T ea;
- const int save_msg_scroll = msg_scroll;
cmdmod_T save_cmdmod;
const int save_reg_executing = reg_executing;
const bool save_pending_end_reg_executing = pending_end_reg_executing;
@@ -1788,9 +1733,10 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
ea.cookie = cookie;
ea.cstack = cstack;
- if (parse_command_modifiers(&ea, &errormsg, false) == FAIL) {
+ if (parse_command_modifiers(&ea, &errormsg, &cmdmod, false) == FAIL) {
goto doend;
}
+ apply_cmdmod(&cmdmod);
after_modifier = ea.cmd;
@@ -2337,12 +2283,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
// ":silent! try" was used, it should only apply to :try itself.
- if (ea.cmdidx == CMD_try && ea.did_esilent > 0) {
- emsg_silent -= ea.did_esilent;
+ if (ea.cmdidx == CMD_try && cmdmod.cmod_did_esilent > 0) {
+ emsg_silent -= cmdmod.cmod_did_esilent;
if (emsg_silent < 0) {
emsg_silent = 0;
}
- ea.did_esilent = 0;
+ cmdmod.cmod_did_esilent = 0;
}
// 7. Execute the command.
@@ -2402,15 +2348,11 @@ doend:
(ea.cmdidx != CMD_SIZE
&& !IS_USER_CMDIDX(ea.cmdidx)) ? cmdnames[(int)ea.cmdidx].cmd_name : NULL);
- undo_cmdmod(&ea, save_msg_scroll);
+ undo_cmdmod(&cmdmod);
cmdmod = save_cmdmod;
reg_executing = save_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
ea.nextcmd = NULL;
}
@@ -2434,25 +2376,25 @@ char *ex_errmsg(const char *const msg, const char *const arg)
/// Parse and skip over command modifiers:
/// - update eap->cmd
-/// - store flags in "cmdmod".
+/// - store flags in "cmod".
/// - Set ex_pressedreturn for an empty command line.
-/// - set msg_silent for ":silent"
-/// - 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
-/// "cmdmod".
+/// @param skip_only if false, undo_cmdmod() must be called later to free
+/// any cmod_filter_regmatch.regprog.
/// @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"
+/// - set msg_silent for ":silent"
+/// - set 'eventignore' to "all" for ":noautocmd"
+///
/// @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, cmdmod_T *cmod, bool skip_only)
{
char *p;
- memset(&cmdmod, 0, sizeof(cmdmod));
- eap->verbose_save = -1;
- eap->save_msg_silent = -1;
+ memset(cmod, 0, sizeof(*cmod));
// Repeat until no more command modifiers are found.
for (;;) {
@@ -2490,48 +2432,48 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
if (!checkforcmd(&eap->cmd, "aboveleft", 3)) {
break;
}
- cmdmod.split |= WSP_ABOVE;
+ cmod->cmod_split |= WSP_ABOVE;
continue;
case 'b':
if (checkforcmd(&eap->cmd, "belowright", 3)) {
- cmdmod.split |= WSP_BELOW;
+ cmod->cmod_split |= WSP_BELOW;
continue;
}
if (checkforcmd(&eap->cmd, "browse", 3)) {
- cmdmod.browse = true;
+ cmod->cmod_flags |= CMOD_BROWSE;
continue;
}
if (!checkforcmd(&eap->cmd, "botright", 2)) {
break;
}
- cmdmod.split |= WSP_BOT;
+ cmod->cmod_split |= WSP_BOT;
continue;
case 'c':
if (!checkforcmd(&eap->cmd, "confirm", 4)) {
break;
}
- cmdmod.confirm = true;
+ cmod->cmod_flags |= CMOD_CONFIRM;
continue;
case 'k':
if (checkforcmd(&eap->cmd, "keepmarks", 3)) {
- cmdmod.keepmarks = true;
+ cmod->cmod_flags |= CMOD_KEEPMARKS;
continue;
}
if (checkforcmd(&eap->cmd, "keepalt", 5)) {
- cmdmod.keepalt = true;
+ cmod->cmod_flags |= CMOD_KEEPALT;
continue;
}
if (checkforcmd(&eap->cmd, "keeppatterns", 5)) {
- cmdmod.keeppatterns = true;
+ cmod->cmod_flags |= CMOD_KEEPPATTERNS;
continue;
}
if (!checkforcmd(&eap->cmd, "keepjumps", 5)) {
break;
}
- cmdmod.keepjumps = true;
+ cmod->cmod_flags |= CMOD_KEEPJUMPS;
continue;
case 'f': { // only accept ":filter {pat} cmd"
@@ -2541,7 +2483,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
break;
}
if (*p == '!') {
- cmdmod.filter_force = true;
+ cmod->cmod_filter_force = true;
p = skipwhite(p + 1);
if (*p == NUL || ends_excmd(*p)) {
break;
@@ -2557,8 +2499,8 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
break;
}
if (!skip_only) {
- cmdmod.filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
- if (cmdmod.filter_regmatch.regprog == NULL) {
+ cmod->cmod_filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
+ if (cmod->cmod_filter_regmatch.regprog == NULL) {
break;
}
}
@@ -2573,70 +2515,52 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
break;
}
eap->cmd = p;
- cmdmod.hide = true;
+ cmod->cmod_flags |= CMOD_HIDE;
continue;
case 'l':
if (checkforcmd(&eap->cmd, "lockmarks", 3)) {
- cmdmod.lockmarks = true;
+ cmod->cmod_flags |= CMOD_LOCKMARKS;
continue;
}
if (!checkforcmd(&eap->cmd, "leftabove", 5)) {
break;
}
- cmdmod.split |= WSP_ABOVE;
+ cmod->cmod_split |= WSP_ABOVE;
continue;
case 'n':
if (checkforcmd(&eap->cmd, "noautocmd", 3)) {
- if (cmdmod.save_ei == NULL && !skip_only) {
- // 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);
- }
+ cmod->cmod_flags |= CMOD_NOAUTOCMD;
continue;
}
if (!checkforcmd(&eap->cmd, "noswapfile", 3)) {
break;
}
- cmdmod.noswapfile = true;
+ cmod->cmod_flags |= CMOD_NOSWAPFILE;
continue;
case 'r':
if (!checkforcmd(&eap->cmd, "rightbelow", 6)) {
break;
}
- cmdmod.split |= WSP_BELOW;
+ cmod->cmod_split |= WSP_BELOW;
continue;
case 's':
if (checkforcmd(&eap->cmd, "sandbox", 3)) {
- if (!skip_only) {
- if (!eap->did_sandbox) {
- sandbox++;
- }
- eap->did_sandbox = true;
- }
+ cmod->cmod_flags |= CMOD_SANDBOX;
continue;
}
if (!checkforcmd(&eap->cmd, "silent", 3)) {
break;
}
- if (!skip_only) {
- if (eap->save_msg_silent == -1) {
- eap->save_msg_silent = msg_silent;
- }
- msg_silent++;
- }
+ cmod->cmod_flags |= CMOD_SILENT;
if (*eap->cmd == '!' && !ascii_iswhite(eap->cmd[-1])) {
// ":silent!", but not "silent !cmd"
eap->cmd = skipwhite(eap->cmd + 1);
- if (!skip_only) {
- emsg_silent++;
- eap->did_esilent++;
- }
+ cmod->cmod_flags |= CMOD_ERRSILENT;
}
continue;
@@ -2647,13 +2571,13 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
false, 1);
if (tabnr == MAXLNUM) {
- cmdmod.tab = tabpage_index(curtab) + 1;
+ cmod->cmod_tab = tabpage_index(curtab) + 1;
} else {
if (tabnr < 0 || tabnr > LAST_TAB_NR) {
*errormsg = _(e_invrange);
return false;
}
- cmdmod.tab = tabnr + 1;
+ cmod->cmod_tab = tabnr + 1;
}
}
eap->cmd = p;
@@ -2662,38 +2586,29 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
if (!checkforcmd(&eap->cmd, "topleft", 2)) {
break;
}
- cmdmod.split |= WSP_TOP;
+ cmod->cmod_split |= WSP_TOP;
continue;
case 'u':
if (!checkforcmd(&eap->cmd, "unsilent", 3)) {
break;
}
- if (!skip_only) {
- if (eap->save_msg_silent == -1) {
- eap->save_msg_silent = msg_silent;
- }
- msg_silent = 0;
- }
+ cmod->cmod_flags |= CMOD_UNSILENT;
continue;
case 'v':
if (checkforcmd(&eap->cmd, "vertical", 4)) {
- cmdmod.split |= WSP_VERT;
+ cmod->cmod_split |= WSP_VERT;
continue;
}
if (!checkforcmd(&p, "verbose", 4)) {
break;
}
- if (!skip_only) {
- if (eap->verbose_save < 0) {
- eap->verbose_save = p_verbose;
- }
- if (ascii_isdigit(*eap->cmd)) {
- p_verbose = atoi(eap->cmd);
- } else {
- p_verbose = 1;
- }
+ if (ascii_isdigit(*eap->cmd)) {
+ // zero means not set, one is verbose == 0, etc.
+ cmod->cmod_verbose = atoi((char *)eap->cmd) + 1;
+ } else {
+ cmod->cmod_verbose = 2; // default: verbose == 1
}
eap->cmd = p;
continue;
@@ -2704,41 +2619,91 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
return OK;
}
-/// Undo and free contents of "cmdmod".
-static void undo_cmdmod(const exarg_T *eap, int save_msg_scroll)
+/// Apply the command modifiers. Saves current state in "cmdmod", call
+/// undo_cmdmod() later.
+static void apply_cmdmod(cmdmod_T *cmod)
+{
+ if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox) {
+ 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 - 1;
+ }
+
+ if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))
+ && cmod->cmod_save_msg_silent == 0) {
+ cmod->cmod_save_msg_silent = msg_silent + 1;
+ cmod->cmod_save_msg_scroll = msg_scroll;
+ }
+ 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) && cmod->cmod_save_ei == NULL) {
+ // Set 'eventignore' to "all".
+ // First save the existing option value for restoring it later.
+ cmod->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 "cmod".
+static void undo_cmdmod(cmdmod_T *cmod)
FUNC_ATTR_NONNULL_ALL
{
- if (eap->verbose_save >= 0) {
- p_verbose = eap->verbose_save;
+ if (cmod->cmod_verbose_save > 0) {
+ p_verbose = cmod->cmod_verbose_save - 1;
+ cmod->cmod_verbose_save = 0;
}
- if (cmdmod.save_ei != NULL) {
+ if (cmod->cmod_did_sandbox) {
+ sandbox--;
+ cmod->cmod_did_sandbox = false;
+ }
+
+ if (cmod->cmod_save_ei != NULL) {
// Restore 'eventignore' to the value before ":noautocmd".
- set_string_option_direct("ei", -1, (char_u *)cmdmod.save_ei, OPT_FREE, SID_NONE);
- free_string_option((char_u *)cmdmod.save_ei);
+ set_string_option_direct("ei", -1, (char_u *)cmod->cmod_save_ei, OPT_FREE, SID_NONE);
+ free_string_option((char_u *)cmod->cmod_save_ei);
+ cmod->cmod_save_ei = NULL;
}
- vim_regfree(cmdmod.filter_regmatch.regprog);
+ vim_regfree(cmod->cmod_filter_regmatch.regprog);
- if (eap->save_msg_silent != -1) {
+ if (cmod->cmod_save_msg_silent > 0) {
// messages could be enabled for a serious error, need to check if the
// counters don't become negative
- if (!did_emsg || msg_silent > eap->save_msg_silent) {
- msg_silent = eap->save_msg_silent;
+ if (!did_emsg || msg_silent > cmod->cmod_save_msg_silent - 1) {
+ msg_silent = cmod->cmod_save_msg_silent - 1;
}
- emsg_silent -= eap->did_esilent;
+ emsg_silent -= cmod->cmod_did_esilent;
if (emsg_silent < 0) {
emsg_silent = 0;
}
// Restore msg_scroll, it's set by file I/O commands, even when no
// message is actually displayed.
- msg_scroll = save_msg_scroll;
+ msg_scroll = cmod->cmod_save_msg_scroll;
// "silent reg" or "silent echo x" inside "redir" leaves msg_col
// somewhere in the line. Put it back in the first column.
if (redirecting()) {
msg_col = 0;
}
+
+ cmod->cmod_save_msg_silent = 0;
+ cmod->cmod_did_esilent = 0;
}
}
@@ -5488,7 +5453,7 @@ static int check_more(int message, bool forceit)
if (!forceit && only_one_window()
&& ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) {
if (message) {
- if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) {
+ if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && curbuf->b_fname != NULL) {
char buff[DIALOG_MSG_SIZE];
vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
@@ -6555,8 +6520,8 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
return result;
}
-/// Add modifiers from "cmdmod.split" to "buf". Set "multi_mods" when one was
-/// added.
+/// Add modifiers from "cmdmod.cmod_split" to "buf". Set "multi_mods" when one
+/// was added.
///
/// @return the number of bytes added
size_t add_win_cmd_modifers(char *buf, bool *multi_mods)
@@ -6564,28 +6529,28 @@ size_t add_win_cmd_modifers(char *buf, bool *multi_mods)
size_t result = 0;
// :aboveleft and :leftabove
- if (cmdmod.split & WSP_ABOVE) {
+ if (cmdmod.cmod_split & WSP_ABOVE) {
result += add_cmd_modifier(buf, "aboveleft", multi_mods);
}
// :belowright and :rightbelow
- if (cmdmod.split & WSP_BELOW) {
+ if (cmdmod.cmod_split & WSP_BELOW) {
result += add_cmd_modifier(buf, "belowright", multi_mods);
}
// :botright
- if (cmdmod.split & WSP_BOT) {
+ if (cmdmod.cmod_split & WSP_BOT) {
result += add_cmd_modifier(buf, "botright", multi_mods);
}
// :tab
- if (cmdmod.tab > 0) {
+ if (cmdmod.cmod_tab > 0) {
result += add_cmd_modifier(buf, "tab", multi_mods);
}
// :topleft
- if (cmdmod.split & WSP_TOP) {
+ if (cmdmod.cmod_split & WSP_TOP) {
result += add_cmd_modifier(buf, "topleft", multi_mods);
}
// :vertical
- if (cmdmod.split & WSP_VERT) {
+ if (cmdmod.cmod_split & WSP_VERT) {
result += add_cmd_modifier(buf, "vertical", multi_mods);
}
return result;
@@ -6597,23 +6562,23 @@ size_t uc_mods(char *buf)
bool multi_mods = false;
typedef struct {
- bool *set;
+ int flag;
char *name;
} mod_entry_T;
static mod_entry_T mod_entries[] = {
- { &cmdmod.browse, "browse" },
- { &cmdmod.confirm, "confirm" },
- { &cmdmod.hide, "hide" },
- { &cmdmod.keepalt, "keepalt" },
- { &cmdmod.keepjumps, "keepjumps" },
- { &cmdmod.keepmarks, "keepmarks" },
- { &cmdmod.keeppatterns, "keeppatterns" },
- { &cmdmod.lockmarks, "lockmarks" },
- { &cmdmod.noswapfile, "noswapfile" }
+ { CMOD_BROWSE, "browse" },
+ { CMOD_CONFIRM, "confirm" },
+ { CMOD_HIDE, "hide" },
+ { CMOD_KEEPALT, "keepalt" },
+ { CMOD_KEEPJUMPS, "keepjumps" },
+ { CMOD_KEEPMARKS, "keepmarks" },
+ { CMOD_KEEPPATTERNS, "keeppatterns" },
+ { CMOD_LOCKMARKS, "lockmarks" },
+ { CMOD_NOSWAPFILE, "noswapfile" }
};
// the modifiers that are simple flags
for (size_t i = 0; i < ARRAY_SIZE(mod_entries); i++) {
- if (*mod_entries[i].set) {
+ if (cmdmod.cmod_flags & mod_entries[i].flag) {
result += add_cmd_modifier(buf, mod_entries[i].name, &multi_mods);
}
}
@@ -6632,7 +6597,7 @@ size_t uc_mods(char *buf)
if (p_verbose > 0) {
result += add_cmd_modifier(buf, "verbose", &multi_mods);
}
- // flags from cmdmod.split
+ // flags from cmdmod.cmod_split
result += add_win_cmd_modifers(buf, &multi_mods);
return result;
@@ -7180,7 +7145,7 @@ void ex_win_close(int forceit, win_T *win, tabpage_T *tp)
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
if (need_hide && !buf_hide(buf) && !forceit) {
- if ((p_confirm || cmdmod.confirm) && p_write) {
+ if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) {
bufref_T bufref;
set_bufref(&bufref, buf);
dialog_changed(buf, false);
@@ -7663,7 +7628,7 @@ void ex_splitview(exarg_T *eap)
// A ":split" in the quickfix window works like ":new". Don't want two
// quickfix windows. But it's OK when doing ":tab split".
- if (bt_quickfix(curbuf) && cmdmod.tab == 0) {
+ if (bt_quickfix(curbuf) && cmdmod.cmod_tab == 0) {
if (eap->cmdidx == CMD_split) {
eap->cmdidx = CMD_new;
}
@@ -7685,7 +7650,7 @@ void ex_splitview(exarg_T *eap)
* Either open new tab page or split the window.
*/
if (use_tab) {
- if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab : eap->addr_count == 0
+ if (win_new_tabpage(cmdmod.cmod_tab != 0 ? cmdmod.cmod_tab : eap->addr_count == 0
? 0 : (int)eap->line2 + 1, (char_u *)eap->arg) != FAIL) {
do_exedit(eap, old_curwin);
apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, false, curbuf);
@@ -7694,7 +7659,7 @@ void ex_splitview(exarg_T *eap)
if (curwin != old_curwin
&& win_valid(old_curwin)
&& old_curwin->w_buffer != curbuf
- && !cmdmod.keepalt) {
+ && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
old_curwin->w_alt_fnum = curbuf->b_fnum;
}
}
@@ -7852,7 +7817,7 @@ static void ex_resize(exarg_T *eap)
}
n = (int)atol(eap->arg);
- if (cmdmod.split & WSP_VERT) {
+ if (cmdmod.cmod_split & WSP_VERT) {
if (*eap->arg == '-' || *eap->arg == '+') {
n += wp->w_width;
} else if (n == 0 && eap->arg[0] == NUL) { // default is very wide
@@ -8023,7 +7988,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
&& curwin != old_curwin
&& win_valid(old_curwin)
&& old_curwin->w_buffer != curbuf
- && !cmdmod.keepalt) {
+ && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
old_curwin->w_alt_fnum = curbuf->b_fnum;
}
@@ -8473,8 +8438,8 @@ static void ex_wincmd(exarg_T *eap)
emsg(_(e_invarg));
} else if (!eap->skip) {
// Pass flags on for ":vertical wincmd ]".
- postponed_split_flags = cmdmod.split;
- postponed_split_tab = cmdmod.tab;
+ postponed_split_flags = cmdmod.cmod_split;
+ postponed_split_tab = cmdmod.cmod_tab;
do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar);
postponed_split_flags = 0;
postponed_split_tab = 0;
@@ -9310,8 +9275,8 @@ static void ex_pedit(exarg_T *eap)
static void ex_stag(exarg_T *eap)
{
postponed_split = -1;
- postponed_split_flags = cmdmod.split;
- postponed_split_tab = cmdmod.tab;
+ postponed_split_flags = cmdmod.cmod_split;
+ postponed_split_tab = cmdmod.cmod_tab;
ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
postponed_split_flags = 0;
postponed_split_tab = 0;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 3210660f14..3065dc462b 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -309,7 +309,6 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
FUNC_ATTR_NONNULL_ALL
{
char *cmd;
- cmdmod_T save_cmdmod = cmdmod;
char *p;
bool delim_optional = false;
int delim;
@@ -346,8 +345,8 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
ea.cmd = (char *)ccline.cmdbuff;
ea.addr_type = ADDR_LINES;
- parse_command_modifiers(&ea, &dummy, true);
- cmdmod = save_cmdmod;
+ cmdmod_T dummy_cmdmod;
+ parse_command_modifiers(&ea, &dummy, &dummy_cmdmod, true);
cmd = skip_range(ea.cmd, NULL);
if (vim_strchr("sgvl", *cmd) == NULL) {
@@ -2433,9 +2432,9 @@ static void cmdpreview_show(CommandLineState *s)
curwin->w_p_cul = false; // Disable 'cursorline' so it doesn't mess up the highlights
curwin->w_p_cuc = false; // Disable 'cursorcolumn' so it doesn't mess up the highlights
p_hls = false; // Don't show search highlighting during live substitution
- cmdmod.split = 0; // Disable :leftabove/botright modifiers
- cmdmod.tab = 0; // Disable :tab modifier
- cmdmod.noswapfile = true; // Disable swap for preview buffer
+ cmdmod.cmod_split = 0; // Disable :leftabove/botright modifiers
+ cmdmod.cmod_tab = 0; // Disable :tab modifier
+ cmdmod.cmod_flags |= CMOD_NOSWAPFILE; // Disable swap for preview buffer
// Open preview buffer if inccommand=split.
if (!icm_split) {
@@ -6074,7 +6073,7 @@ void add_to_history(int histype, char_u *new_entry, int in_map, int sep)
}
assert(histype != HIST_DEFAULT);
- if (cmdmod.keeppatterns && histype == HIST_SEARCH) {
+ if ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) && histype == HIST_SEARCH) {
return;
}
@@ -6604,8 +6603,8 @@ static int open_cmdwin(void)
pum_undisplay(true);
// don't use a new tab page
- cmdmod.tab = 0;
- cmdmod.noswapfile = 1;
+ cmdmod.cmod_tab = 0;
+ cmdmod.cmod_flags |= CMOD_NOSWAPFILE;
// Create a window for the command-line buffer.
if (win_split((int)p_cwh, WSP_BOT) == FAIL) {
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 8d8c10f823..4c1dd63b8f 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1890,7 +1890,7 @@ failed:
check_cursor_lnum();
beginline(BL_WHITE | BL_FIX); // on first non-blank
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set '[ and '] marks to the newly read lines.
curbuf->b_op_start.lnum = from + 1;
curbuf->b_op_start.col = 0;
@@ -2425,7 +2425,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
if (buf == NULL || (buf->b_ml.ml_mfp == NULL && !empty_memline)
|| did_cmd || nofile_err
|| aborting()) {
- if (buf != NULL && cmdmod.lockmarks) {
+ if (buf != NULL && (cmdmod.cmod_flags & CMOD_LOCKMARKS)) {
// restore the original '[ and '] positions
buf->b_op_start = orig_start;
buf->b_op_end = orig_end;
@@ -2511,7 +2511,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
}
}
- if (cmdmod.lockmarks) {
+ if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
// restore the original '[ and '] positions
buf->b_op_start = orig_start;
buf->b_op_end = orig_end;
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/if_cscope.c b/src/nvim/if_cscope.c
index af0d32ad9c..f01f4fc771 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -187,8 +187,8 @@ static void do_cscope_general(exarg_T *eap, int make_split)
return;
}
postponed_split = -1;
- postponed_split_flags = cmdmod.split;
- postponed_split_tab = cmdmod.tab;
+ postponed_split_flags = cmdmod.cmod_split;
+ postponed_split_tab = cmdmod.cmod_tab;
}
cmdp->func(eap);
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 215aae9430..30ae274607 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1918,55 +1918,55 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
lua_newtable(lstate); // smods table
- lua_pushinteger(lstate, cmdmod.tab);
+ lua_pushinteger(lstate, cmdmod.cmod_tab);
lua_setfield(lstate, -2, "tab");
- lua_pushinteger(lstate, eap->verbose_save != -1 ? p_verbose : -1);
+ lua_pushinteger(lstate, cmdmod.cmod_verbose - 1);
lua_setfield(lstate, -2, "verbose");
- if (cmdmod.split & WSP_ABOVE) {
+ if (cmdmod.cmod_split & WSP_ABOVE) {
lua_pushstring(lstate, "aboveleft");
- } else if (cmdmod.split & WSP_BELOW) {
+ } else if (cmdmod.cmod_split & WSP_BELOW) {
lua_pushstring(lstate, "belowright");
- } else if (cmdmod.split & WSP_TOP) {
+ } else if (cmdmod.cmod_split & WSP_TOP) {
lua_pushstring(lstate, "topleft");
- } else if (cmdmod.split & WSP_BOT) {
+ } else if (cmdmod.cmod_split & WSP_BOT) {
lua_pushstring(lstate, "botright");
} else {
lua_pushstring(lstate, "");
}
lua_setfield(lstate, -2, "split");
- lua_pushboolean(lstate, cmdmod.split & WSP_VERT);
+ lua_pushboolean(lstate, cmdmod.cmod_split & WSP_VERT);
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_pushboolean(lstate, eap->did_esilent);
+ lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_ERRSILENT);
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_pushboolean(lstate, cmdmod.save_ei != NULL);
+ lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_NOAUTOCMD);
lua_setfield(lstate, -2, "noautocmd");
typedef struct {
- bool *set;
+ int flag;
char *name;
} mod_entry_T;
static mod_entry_T mod_entries[] = {
- { &cmdmod.browse, "browse" },
- { &cmdmod.confirm, "confirm" },
- { &cmdmod.hide, "hide" },
- { &cmdmod.keepalt, "keepalt" },
- { &cmdmod.keepjumps, "keepjumps" },
- { &cmdmod.keepmarks, "keepmarks" },
- { &cmdmod.keeppatterns, "keeppatterns" },
- { &cmdmod.lockmarks, "lockmarks" },
- { &cmdmod.noswapfile, "noswapfile" }
+ { CMOD_BROWSE, "browse" },
+ { CMOD_CONFIRM, "confirm" },
+ { CMOD_HIDE, "hide" },
+ { CMOD_KEEPALT, "keepalt" },
+ { CMOD_KEEPJUMPS, "keepjumps" },
+ { CMOD_KEEPMARKS, "keepmarks" },
+ { CMOD_KEEPPATTERNS, "keeppatterns" },
+ { CMOD_LOCKMARKS, "lockmarks" },
+ { CMOD_NOSWAPFILE, "noswapfile" }
};
// The modifiers that are simple flags
for (size_t i = 0; i < ARRAY_SIZE(mod_entries); i++) {
- lua_pushboolean(lstate, *mod_entries[i].set);
+ lua_pushboolean(lstate, cmdmod.cmod_flags & mod_entries[i].flag);
lua_setfield(lstate, -2, mod_entries[i].name);
}
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 7b7441ebcf..8d1a917600 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -171,7 +171,7 @@ void setpcmark(void)
xfmark_T *fm;
// for :global the mark is set only once
- if (global_busy || listcmd_busy || cmdmod.keepjumps) {
+ if (global_busy || listcmd_busy || (cmdmod.cmod_flags & CMOD_KEEPJUMPS)) {
return;
}
@@ -990,7 +990,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, linenr_T amount
return;
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// named marks, lower case and upper case
for (i = 0; i < NMARKS; i++) {
ONE_ADJUST(&(curbuf->b_namedm[i].mark.lnum));
@@ -1059,7 +1059,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, linenr_T amount
* Adjust items in all windows related to the current buffer.
*/
FOR_ALL_TAB_WINDOWS(tab, win) {
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Marks in the jumplist. When deleting lines, this may create
// duplicate marks in the jumplist, they will be removed later.
for (i = 0; i < win->w_jumplistlen; i++) {
@@ -1070,7 +1070,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, linenr_T amount
}
if (win->w_buffer == curbuf) {
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// marks in the tag stack
for (i = 0; i < win->w_tagstacklen; i++) {
if (win->w_tagstack[i].fmark.fnum == fnum) {
@@ -1159,7 +1159,7 @@ void mark_col_adjust(linenr_T lnum, colnr_T mincol, linenr_T lnum_amount, long c
int fnum = curbuf->b_fnum;
pos_T *posp;
- if ((col_amount == 0L && lnum_amount == 0L) || cmdmod.lockmarks) {
+ if ((col_amount == 0L && lnum_amount == 0L) || (cmdmod.cmod_flags & CMOD_LOCKMARKS)) {
return; // nothing to do
}
// named marks, lower case and upper case
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 81d89ef3df..21b0ab89d7 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -264,7 +264,7 @@ int ml_open(buf_T *buf)
buf->b_ml.ml_chunksize = NULL;
buf->b_ml.ml_usedchunks = 0;
- if (cmdmod.noswapfile) {
+ if (cmdmod.cmod_flags & CMOD_NOSWAPFILE) {
buf->b_p_swf = false;
}
@@ -391,7 +391,7 @@ void ml_setname(buf_T *buf)
* When 'updatecount' is 0 and 'noswapfile' there is no swap file.
* For help files we will make a swap file now.
*/
- if (p_uc != 0 && !cmdmod.noswapfile) {
+ if (p_uc != 0 && (cmdmod.cmod_flags & CMOD_NOSWAPFILE) == 0) {
ml_open_file(buf); // create a swap file
}
return;
@@ -475,7 +475,8 @@ void ml_open_file(buf_T *buf)
char_u *dirp;
mfp = buf->b_ml.ml_mfp;
- if (mfp == NULL || mfp->mf_fd >= 0 || !buf->b_p_swf || cmdmod.noswapfile
+ if (mfp == NULL || mfp->mf_fd >= 0 || !buf->b_p_swf
+ || (cmdmod.cmod_flags & CMOD_NOSWAPFILE)
|| buf->terminal) {
return; // nothing to do
}
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 23ceb0ba4c..182f8494a1 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -2324,12 +2324,12 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
/// "pattern".
bool message_filtered(char_u *msg)
{
- if (cmdmod.filter_regmatch.regprog == NULL) {
+ if (cmdmod.cmod_filter_regmatch.regprog == NULL) {
return false;
}
- bool match = vim_regexec(&cmdmod.filter_regmatch, msg, (colnr_T)0);
- return cmdmod.filter_force ? match : !match;
+ bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, (colnr_T)0);
+ return cmdmod.cmod_filter_force ? match : !match;
}
/// including horizontal separator
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 0f202b2fd3..ac13807bd3 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -268,7 +268,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount)
msg_attr_keep((char *)IObuff, 0, true, false);
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set "'[" and "']" marks.
curbuf->b_op_start = oap->start;
curbuf->b_op_end.lnum = oap->end.lnum;
@@ -693,7 +693,7 @@ void op_reindent(oparg_T *oap, Indenter how)
"%" PRId64 " lines indented ", i),
(int64_t)i);
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// set '[ and '] marks
curbuf->b_op_start = oap->start;
curbuf->b_op_end = oap->end;
@@ -1793,7 +1793,7 @@ int op_delete(oparg_T *oap)
msgmore(curbuf->b_ml.ml_line_count - old_lcount);
setmarks:
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
if (oap->motion_type == kMTBlockWise) {
curbuf->b_op_end.lnum = oap->end.lnum;
curbuf->b_op_end.col = oap->start.col;
@@ -2063,7 +2063,7 @@ static int op_replace(oparg_T *oap, int c)
check_cursor();
changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1, 0L, true);
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set "'[" and "']" marks.
curbuf->b_op_start = oap->start;
curbuf->b_op_end = oap->end;
@@ -2133,7 +2133,7 @@ void op_tilde(oparg_T *oap)
redraw_curbuf_later(INVERTED);
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set '[ and '] marks.
curbuf->b_op_start = oap->start;
curbuf->b_op_end = oap->end;
@@ -2825,7 +2825,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
}
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set "'[" and "']" marks.
curbuf->b_op_start = oap->start;
curbuf->b_op_end = oap->end;
@@ -3708,7 +3708,7 @@ error:
curwin->w_set_curswant = TRUE;
end:
- if (cmdmod.lockmarks) {
+ if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
curbuf->b_op_start = orig_start;
curbuf->b_op_end = orig_end;
}
@@ -4051,7 +4051,7 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions
// and setup the array of space strings lengths
for (t = 0; t < (linenr_T)count; t++) {
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
- if (t == 0 && setmark && !cmdmod.lockmarks) {
+ if (t == 0 && setmark && (cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set the '[ mark.
curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum;
curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr);
@@ -4172,7 +4172,7 @@ int do_join(size_t count, int insert_space, int save_undo, int use_formatoptions
ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
- if (setmark && !cmdmod.lockmarks) {
+ if (setmark && (cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set the '] mark.
curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum;
curwin->w_buffer->b_op_end.col = sumsize;
@@ -4309,7 +4309,7 @@ static void op_format(oparg_T *oap, int keep_cursor)
redraw_curbuf_later(INVERTED);
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// Set '[ mark at the start of the formatted area
curbuf->b_op_start = oap->start;
}
@@ -4334,7 +4334,7 @@ static void op_format(oparg_T *oap, int keep_cursor)
old_line_count = curbuf->b_ml.ml_line_count - old_line_count;
msgmore(old_line_count);
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// put '] mark on the end of the formatted area
curbuf->b_op_end = curwin->w_cursor;
}
@@ -4945,7 +4945,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd)
// Set '[ mark if something changed. Keep the last end
// position from do_addsub().
- if (change_cnt > 0 && !cmdmod.lockmarks) {
+ if (change_cnt > 0 && (cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
curbuf->b_op_start = startpos;
}
@@ -5299,7 +5299,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
}
}
- if (!cmdmod.lockmarks) {
+ if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
// set the '[ and '] marks
curbuf->b_op_start = startpos;
curbuf->b_op_end = endpos;
@@ -6155,7 +6155,7 @@ static void op_function(const oparg_T *oap)
virtual_op = save_virtual_op;
finish_op = save_finish_op;
- if (cmdmod.lockmarks) {
+ if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
curbuf->b_op_start = orig_start;
curbuf->b_op_end = orig_end;
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index ca9c7468cf..8f19ebf5ba 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -6515,7 +6515,7 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_ml_nobin = p_ml_nobin;
buf->b_p_inf = p_inf;
COPY_OPT_SCTX(buf, BV_INF);
- if (cmdmod.noswapfile) {
+ if (cmdmod.cmod_flags & CMOD_NOSWAPFILE) {
buf->b_p_swf = false;
} else {
buf->b_p_swf = p_swf;
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 22e42d2d74..868a68969c 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2493,7 +2493,7 @@ static int jump_to_help_window(qf_info_T *qi, bool newwin, int *opened_window)
{
win_T *wp = NULL;
- if (cmdmod.tab != 0 || newwin) {
+ if (cmdmod.cmod_tab != 0 || newwin) {
wp = NULL;
} else {
wp = qf_find_help_win();
@@ -2505,7 +2505,7 @@ static int jump_to_help_window(qf_info_T *qi, bool newwin, int *opened_window)
// Split off help window; put it at far top if no position
// specified, the current window is vertically split and narrow.
int flags = WSP_HELP;
- if (cmdmod.split == 0
+ if (cmdmod.cmod_split == 0
&& curwin->w_width != Columns
&& curwin->w_width < 80) {
flags |= WSP_TOP;
@@ -2880,7 +2880,7 @@ static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, int
qfltype_T qfl_type = qfl->qfl_type;
// For ":helpgrep" find a help window or open one.
- if (qf_ptr->qf_type == 1 && (!bt_help(curwin->w_buffer) || cmdmod.tab != 0)) {
+ if (qf_ptr->qf_type == 1 && (!bt_help(curwin->w_buffer) || cmdmod.cmod_tab != 0)) {
if (jump_to_help_window(qi, newwin, opened_window) == FAIL) {
return FAIL;
}
@@ -3655,13 +3655,13 @@ static int qf_open_new_cwindow(qf_info_T *qi, int height)
// The current window becomes the previous window afterwards.
win_T *const win = curwin;
- if (IS_QF_STACK(qi) && cmdmod.split == 0) {
+ if (IS_QF_STACK(qi) && cmdmod.cmod_split == 0) {
// Create the new quickfix window at the very bottom, except when
// :belowright or :aboveleft is used.
win_goto(lastwin);
}
// Default is to open the window below the current window
- if (cmdmod.split == 0) {
+ if (cmdmod.cmod_split == 0) {
flags = WSP_BELOW;
}
flags |= WSP_NEWLOC;
@@ -3747,9 +3747,9 @@ void ex_copen(exarg_T *eap)
reset_VIsual_and_resel(); // stop Visual mode
// Find an existing quickfix window, or open a new one.
- if (cmdmod.tab == 0) {
+ if (cmdmod.cmod_tab == 0) {
status = qf_goto_cwindow(qi, eap->addr_count != 0, height,
- cmdmod.split & WSP_VERT);
+ cmdmod.cmod_split & WSP_VERT);
}
if (status == FAIL) {
if (qf_open_new_cwindow(qi, height) == FAIL) {
@@ -5510,7 +5510,7 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo
// with the same name.
wipe_dummy_buffer(buf, dirname_start);
buf = NULL;
- } else if (!cmdmod.hide
+ } else if ((cmdmod.cmod_flags & CMOD_HIDE) == 0
|| buf->b_p_bh[0] == 'u' // "unload"
|| buf->b_p_bh[0] == 'w' // "wipe"
|| buf->b_p_bh[0] == 'd') { // "delete"
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 108a86b8f5..4243dce479 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -176,7 +176,7 @@ int search_regcomp(char_u *pat, int pat_save, int pat_use, int options, regmmatc
* Save the currently used pattern in the appropriate place,
* unless the pattern should not be remembered.
*/
- if (!(options & SEARCH_KEEP) && !cmdmod.keeppatterns) {
+ if (!(options & SEARCH_KEEP) && (cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0) {
// search or global command
if (pat_save == RE_SEARCH || pat_save == RE_BOTH) {
save_re_pat(RE_SEARCH, pat, magic);
@@ -1420,7 +1420,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
curwin->w_set_curswant = TRUE;
end_do_search:
- if ((options & SEARCH_KEEP) || cmdmod.keeppatterns) {
+ if ((options & SEARCH_KEEP) || (cmdmod.cmod_flags & CMOD_KEEPPATTERNS)) {
spats[0].off = old_off;
}
xfree(msgbuf);
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 06a45d3cc6..b9f6494459 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -2772,7 +2772,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
}
}
if (getfile_result == GETFILE_UNUSED
- && (postponed_split || cmdmod.tab != 0)) {
+ && (postponed_split || cmdmod.cmod_tab != 0)) {
if (win_split(postponed_split > 0 ? postponed_split : 0,
postponed_split_flags) == FAIL) {
RedrawingDisabled--;
diff --git a/src/nvim/window.c b/src/nvim/window.c
index e08db2261b..95796b29a1 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -569,7 +569,7 @@ wingotofile:
case 'f': // CTRL-W gf: "gf" in a new tab page
case 'F': // CTRL-W gF: "gF" in a new tab page
- cmdmod.tab = tabpage_index(curtab) + 1;
+ cmdmod.cmod_tab = tabpage_index(curtab) + 1;
nchar = xchar;
goto wingotofile;
case 't': // CTRL-W gt: go to next tab page
@@ -985,7 +985,7 @@ int win_split(int size, int flags)
}
// Add flags from ":vertical", ":topleft" and ":botright".
- flags |= cmdmod.split;
+ flags |= cmdmod.cmod_split;
if ((flags & WSP_TOP) && (flags & WSP_BOT)) {
emsg(_("E442: Can't split topleft and botright at the same time"));
return FAIL;
@@ -3882,7 +3882,7 @@ void close_others(int message, int forceit)
continue;
}
if (!r) {
- if (message && (p_confirm || cmdmod.confirm) && p_write) {
+ if (message && (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) {
dialog_changed(wp->w_buffer, false);
if (!win_valid(wp)) { // autocommands messed wp up
nextwp = firstwin;
@@ -4136,10 +4136,10 @@ int win_new_tabpage(int after, char_u *filename)
*/
int may_open_tabpage(void)
{
- int n = (cmdmod.tab == 0) ? postponed_split_tab : cmdmod.tab;
+ int n = (cmdmod.cmod_tab == 0) ? postponed_split_tab : cmdmod.cmod_tab;
if (n != 0) {
- cmdmod.tab = 0; // reset it to avoid doing it twice
+ cmdmod.cmod_tab = 0; // reset it to avoid doing it twice
postponed_split_tab = 0;
return win_new_tabpage(n, NULL);
}