mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.1898: command modifier parsing always uses global cmdmod
Problem: Command modifier parsing always uses global cmdmod.
Solution: Pass in cmdmod_T to use. Rename struct fields consistently.
e100440158
This commit is contained in:
parent
dad898b665
commit
6130b4a84b
@ -222,27 +222,27 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
|
|||||||
PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_ERRSILENT));
|
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, "sandbox", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX));
|
||||||
PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOAUTOCMD));
|
PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOAUTOCMD));
|
||||||
PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.tab));
|
PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.cmod_tab));
|
||||||
PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.verbose));
|
PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.verbose));
|
||||||
PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.browse));
|
PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_BROWSE));
|
||||||
PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.confirm));
|
PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_CONFIRM));
|
||||||
PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.hide));
|
PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_HIDE));
|
||||||
PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.keepalt));
|
PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPALT));
|
||||||
PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.keepjumps));
|
PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPJUMPS));
|
||||||
PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.keepmarks));
|
PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPMARKS));
|
||||||
PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.keeppatterns));
|
PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_KEEPPATTERNS));
|
||||||
PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.lockmarks));
|
PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_LOCKMARKS));
|
||||||
PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.noswapfile));
|
PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_NOSWAPFILE));
|
||||||
PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.split & WSP_VERT));
|
PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_split & WSP_VERT));
|
||||||
|
|
||||||
const char *split;
|
const char *split;
|
||||||
if (cmdinfo.cmdmod.split & WSP_BOT) {
|
if (cmdinfo.cmdmod.cmod_split & WSP_BOT) {
|
||||||
split = "botright";
|
split = "botright";
|
||||||
} else if (cmdinfo.cmdmod.split & WSP_TOP) {
|
} else if (cmdinfo.cmdmod.cmod_split & WSP_TOP) {
|
||||||
split = "topleft";
|
split = "topleft";
|
||||||
} else if (cmdinfo.cmdmod.split & WSP_BELOW) {
|
} else if (cmdinfo.cmdmod.cmod_split & WSP_BELOW) {
|
||||||
split = "belowright";
|
split = "belowright";
|
||||||
} else if (cmdinfo.cmdmod.split & WSP_ABOVE) {
|
} else if (cmdinfo.cmdmod.cmod_split & WSP_ABOVE) {
|
||||||
split = "aboveleft";
|
split = "aboveleft";
|
||||||
} else {
|
} else {
|
||||||
split = "";
|
split = "";
|
||||||
@ -516,7 +516,7 @@ 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) {
|
if (mods.tab.type != kObjectTypeInteger || mods.tab.data.integer < 0) {
|
||||||
VALIDATION_ERROR("'mods.tab' must be a non-negative Integer");
|
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 (HAS_KEY(mods.verbose)) {
|
||||||
@ -530,7 +530,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
|||||||
|
|
||||||
bool vertical;
|
bool vertical;
|
||||||
OBJ_TO_BOOL(vertical, mods.vertical, false, "'mods.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 (HAS_KEY(mods.split)) {
|
||||||
if (mods.split.type != kObjectTypeString) {
|
if (mods.split.type != kObjectTypeString) {
|
||||||
@ -541,14 +541,14 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
|||||||
// Empty string, do nothing.
|
// Empty string, do nothing.
|
||||||
} else if (STRCMP(mods.split.data.string.data, "aboveleft") == 0
|
} else if (STRCMP(mods.split.data.string.data, "aboveleft") == 0
|
||||||
|| STRCMP(mods.split.data.string.data, "leftabove") == 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
|
} else if (STRCMP(mods.split.data.string.data, "belowright") == 0
|
||||||
|| STRCMP(mods.split.data.string.data, "rightbelow") == 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) {
|
} 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) {
|
} else if (STRCMP(mods.split.data.string.data, "botright") == 0) {
|
||||||
cmdinfo.cmdmod.split |= WSP_BOT;
|
cmdinfo.cmdmod.cmod_split |= WSP_BOT;
|
||||||
} else {
|
} else {
|
||||||
VALIDATION_ERROR("Invalid value for 'mods.split'");
|
VALIDATION_ERROR("Invalid value for 'mods.split'");
|
||||||
}
|
}
|
||||||
@ -558,15 +558,15 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
|||||||
OBJ_TO_CMOD_FLAG(CMOD_ERRSILENT, mods.emsg_silent, false, "'mods.emsg_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_SANDBOX, mods.sandbox, false, "'mods.sandbox'");
|
||||||
OBJ_TO_CMOD_FLAG(CMOD_NOAUTOCMD, mods.noautocmd, false, "'mods.noautocmd'");
|
OBJ_TO_CMOD_FLAG(CMOD_NOAUTOCMD, mods.noautocmd, false, "'mods.noautocmd'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.browse, mods.browse, false, "'mods.browse'");
|
OBJ_TO_CMOD_FLAG(CMOD_BROWSE, mods.browse, false, "'mods.browse'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.confirm, mods.confirm, false, "'mods.confirm'");
|
OBJ_TO_CMOD_FLAG(CMOD_CONFIRM, mods.confirm, false, "'mods.confirm'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.hide, mods.hide, false, "'mods.hide'");
|
OBJ_TO_CMOD_FLAG(CMOD_HIDE, mods.hide, false, "'mods.hide'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.keepalt, mods.keepalt, false, "'mods.keepalt'");
|
OBJ_TO_CMOD_FLAG(CMOD_KEEPALT, mods.keepalt, false, "'mods.keepalt'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.keepjumps, mods.keepjumps, false, "'mods.keepjumps'");
|
OBJ_TO_CMOD_FLAG(CMOD_KEEPJUMPS, mods.keepjumps, false, "'mods.keepjumps'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.keepmarks, mods.keepmarks, false, "'mods.keepmarks'");
|
OBJ_TO_CMOD_FLAG(CMOD_KEEPMARKS, mods.keepmarks, false, "'mods.keepmarks'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.keeppatterns, mods.keeppatterns, false, "'mods.keeppatterns'");
|
OBJ_TO_CMOD_FLAG(CMOD_KEEPPATTERNS, mods.keeppatterns, false, "'mods.keeppatterns'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.lockmarks, mods.lockmarks, false, "'mods.lockmarks'");
|
OBJ_TO_CMOD_FLAG(CMOD_LOCKMARKS, mods.lockmarks, false, "'mods.lockmarks'");
|
||||||
OBJ_TO_BOOL(cmdinfo.cmdmod.noswapfile, mods.noswapfile, false, "'mods.noswapfile'");
|
OBJ_TO_CMOD_FLAG(CMOD_NOSWAPFILE, mods.noswapfile, false, "'mods.noswapfile'");
|
||||||
|
|
||||||
if ((cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX) && !(ea.argt & EX_SBOXOK)) {
|
if ((cmdinfo.cmdmod.cmod_flags & CMOD_SANDBOX) && !(ea.argt & EX_SBOXOK)) {
|
||||||
VALIDATION_ERROR("Command cannot be run in sandbox");
|
VALIDATION_ERROR("Command cannot be run in sandbox");
|
||||||
@ -667,8 +667,8 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
|
|||||||
StringBuilder cmdline = KV_INITIAL_VALUE;
|
StringBuilder cmdline = KV_INITIAL_VALUE;
|
||||||
|
|
||||||
// Add command modifiers
|
// Add command modifiers
|
||||||
if (cmdinfo->cmdmod.tab != 0) {
|
if (cmdinfo->cmdmod.cmod_tab != 0) {
|
||||||
kv_printf(cmdline, "%dtab ", cmdinfo->cmdmod.tab - 1);
|
kv_printf(cmdline, "%dtab ", cmdinfo->cmdmod.cmod_tab - 1);
|
||||||
}
|
}
|
||||||
if (cmdinfo->verbose != -1) {
|
if (cmdinfo->verbose != -1) {
|
||||||
kv_printf(cmdline, "%dverbose ", cmdinfo->verbose);
|
kv_printf(cmdline, "%dverbose ", cmdinfo->verbose);
|
||||||
@ -680,7 +680,7 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
|
|||||||
kv_concat(cmdline, "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:
|
case WSP_ABOVE:
|
||||||
kv_concat(cmdline, "aboveleft ");
|
kv_concat(cmdline, "aboveleft ");
|
||||||
break;
|
break;
|
||||||
@ -704,18 +704,18 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.split & WSP_VERT, "vertical ");
|
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_SANDBOX, "sandbox ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_NOAUTOCMD, "noautocmd ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_NOAUTOCMD, "noautocmd ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.browse, "browse ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_BROWSE, "browse ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.confirm, "confirm ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_CONFIRM, "confirm ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.hide, "hide ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_HIDE, "hide ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.keepalt, "keepalt ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPALT, "keepalt ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.keepjumps, "keepjumps ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPJUMPS, "keepjumps ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.keepmarks, "keepmarks ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPMARKS, "keepmarks ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.keeppatterns, "keeppatterns ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_KEEPPATTERNS, "keeppatterns ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.lockmarks, "lockmarks ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_LOCKMARKS, "lockmarks ");
|
||||||
CMDLINE_APPEND_IF(cmdinfo->cmdmod.noswapfile, "noswapfile ");
|
CMDLINE_APPEND_IF(cmdinfo->cmdmod.cmod_flags & CMOD_NOSWAPFILE, "noswapfile ");
|
||||||
#undef CMDLINE_APPEND_IF
|
#undef CMDLINE_APPEND_IF
|
||||||
|
|
||||||
// Command range / count.
|
// Command range / count.
|
||||||
|
@ -1191,7 +1191,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!forceit && bufIsChanged(buf)) {
|
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);
|
dialog_changed(buf, false);
|
||||||
if (!bufref_valid(&bufref)) {
|
if (!bufref_valid(&bufref)) {
|
||||||
// Autocommand deleted buffer, oops! It's not changed now.
|
// 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 (!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)) {
|
if (!dialog_close_terminal(buf)) {
|
||||||
return FAIL;
|
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.
|
// Check if the current buffer may be abandoned.
|
||||||
if (action == DOBUF_GOTO && !can_abandon(curbuf, forceit)) {
|
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;
|
bufref_T bufref;
|
||||||
set_bufref(&bufref, buf);
|
set_bufref(&bufref, buf);
|
||||||
dialog_changed(curbuf, false);
|
dialog_changed(curbuf, false);
|
||||||
@ -1439,7 +1439,7 @@ void set_curbuf(buf_T *buf, int action)
|
|||||||
long old_tw = curbuf->b_p_tw;
|
long old_tw = curbuf->b_p_tw;
|
||||||
|
|
||||||
setpcmark();
|
setpcmark();
|
||||||
if (!cmdmod.keepalt) {
|
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
|
||||||
curwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file
|
curwin->w_alt_fnum = curbuf->b_fnum; // remember alternate file
|
||||||
}
|
}
|
||||||
buflist_altfpos(curwin); // remember curpos
|
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
|
// Create a buffer. 'buflisted' is not set if it's a new buffer
|
||||||
buf = buflist_new(ffname, sfname, lnum, 0);
|
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;
|
curwin->w_alt_fnum = buf->b_fnum;
|
||||||
}
|
}
|
||||||
return buf;
|
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
|
alist_T *alist; // argument list to be used
|
||||||
buf_T *buf;
|
buf_T *buf;
|
||||||
tabpage_T *tpnext;
|
tabpage_T *tpnext;
|
||||||
int had_tab = cmdmod.tab;
|
int had_tab = cmdmod.cmod_tab;
|
||||||
win_T *old_curwin, *last_curwin;
|
win_T *old_curwin, *last_curwin;
|
||||||
tabpage_T *old_curtab, *last_curtab;
|
tabpage_T *old_curtab, *last_curtab;
|
||||||
win_T *new_curwin = NULL;
|
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.
|
// When ":tab" was used open a new tab for a new window repeatedly.
|
||||||
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) {
|
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;
|
int r;
|
||||||
long count; // Maximum number of windows to open.
|
long count; // Maximum number of windows to open.
|
||||||
int all; // When true also load inactive buffers.
|
int all; // When true also load inactive buffers.
|
||||||
int had_tab = cmdmod.tab;
|
int had_tab = cmdmod.cmod_tab;
|
||||||
tabpage_T *tpnext;
|
tabpage_T *tpnext;
|
||||||
|
|
||||||
if (eap->addr_count == 0) { // make as many windows as possible
|
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) {
|
for (wp = firstwin; wp != NULL; wp = wpnext) {
|
||||||
wpnext = wp->w_next;
|
wpnext = wp->w_next;
|
||||||
if ((wp->w_buffer->b_nwindows > 1
|
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
|
? wp->w_height + wp->w_hsep_height + wp->w_status_height < Rows - p_ch
|
||||||
- tabline_height() - global_stl_height()
|
- tabline_height() - global_stl_height()
|
||||||
: wp->w_width != Columns)
|
: 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.
|
// When ":tab" was used open a new tab for a new window repeatedly.
|
||||||
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) {
|
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) {
|
||||||
cmdmod.tab = 9999;
|
cmdmod.cmod_tab = 9999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
autocmd_no_enter--;
|
autocmd_no_enter--;
|
||||||
@ -5322,7 +5322,7 @@ bool buf_hide(const buf_T *const buf)
|
|||||||
case 'h':
|
case 'h':
|
||||||
return true; // "hide"
|
return true; // "hide"
|
||||||
}
|
}
|
||||||
return p_hid || cmdmod.hide;
|
return p_hid || (cmdmod.cmod_flags & CMOD_HIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return special buffer name or
|
/// @return special buffer name or
|
||||||
|
@ -148,7 +148,7 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, linenr_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the '. mark
|
// 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);
|
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
|
// Create a new entry if a new undo-able change was started or we
|
||||||
|
@ -790,14 +790,14 @@ static int diff_write(buf_T *buf, diffin_T *din)
|
|||||||
// Always use 'fileformat' set to "unix".
|
// Always use 'fileformat' set to "unix".
|
||||||
char_u *save_ff = buf->b_p_ff;
|
char_u *save_ff = buf->b_p_ff;
|
||||||
buf->b_p_ff = vim_strsave((char_u *)FF_UNIX);
|
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,
|
// Writing the buffer is an implementation detail of performing the diff,
|
||||||
// so it shouldn't update the '[ and '] marks.
|
// 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,
|
int r = buf_write(buf, (char *)din->din_fname, NULL,
|
||||||
(linenr_T)1, buf->b_ml.ml_line_count,
|
(linenr_T)1, buf->b_ml.ml_line_count,
|
||||||
NULL, false, false, false, true);
|
NULL, false, false, false, true);
|
||||||
cmdmod.lockmarks = save_lockmarks;
|
cmdmod.cmod_flags = save_cmod_flags;
|
||||||
free_string_option(buf->b_p_ff);
|
free_string_option(buf->b_p_ff);
|
||||||
buf->b_p_ff = save_ff;
|
buf->b_p_ff = save_ff;
|
||||||
return r;
|
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
|
// 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) {
|
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
|
||||||
// Pretend it was a ":split fname" command
|
// Pretend it was a ":split fname" command
|
||||||
@ -1323,7 +1323,7 @@ void ex_diffsplit(exarg_T *eap)
|
|||||||
set_fraction(curwin);
|
set_fraction(curwin);
|
||||||
|
|
||||||
// don't use a new tab page, each tab page has its own diffs
|
// 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) {
|
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
|
||||||
// Pretend it was a ":split fname" command
|
// Pretend it was a ":split fname" command
|
||||||
|
@ -7956,7 +7956,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remember the last Insert position in the '^ mark.
|
// 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);
|
RESET_FMARK(&curbuf->b_last_insert, curwin->w_cursor, curbuf->b_fnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,7 +981,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
|||||||
foldMoveRange(win, &win->w_folds, line1, line2, 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_start.lnum = dest - num_lines + 1;
|
||||||
curbuf->b_op_end.lnum = dest;
|
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);
|
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_start.lnum = dest + 1;
|
||||||
curbuf->b_op_end.lnum = dest + num_lines;
|
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;
|
curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
|
||||||
}
|
}
|
||||||
mark_adjust_nofold(last_line - num_lines + 1, last_line,
|
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;
|
char *p;
|
||||||
|
|
||||||
count = line2 - line1 + 1;
|
count = line2 - line1 + 1;
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
curbuf->b_op_start.lnum = n + 1;
|
curbuf->b_op_start.lnum = n + 1;
|
||||||
curbuf->b_op_end.lnum = n + count;
|
curbuf->b_op_end.lnum = n + count;
|
||||||
curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
|
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;
|
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
|
// Temporarily disable lockmarks since that's needed to propagate changed
|
||||||
// regions of the buffer for foldUpdate(), linecount, etc.
|
// regions of the buffer for foldUpdate(), linecount, etc.
|
||||||
cmdmod.lockmarks = false;
|
cmdmod.cmod_flags &= ~CMOD_LOCKMARKS;
|
||||||
|
|
||||||
cursor_save = curwin->w_cursor;
|
cursor_save = curwin->w_cursor;
|
||||||
linecount = line2 - line1 + 1;
|
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 (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
|
// TODO(bfredl): Currently not active for extmarks. What would we
|
||||||
// do if columns don't match, assume added/deleted bytes at the
|
// do if columns don't match, assume added/deleted bytes at the
|
||||||
// end of each line?
|
// end of each line?
|
||||||
@ -1471,11 +1472,11 @@ error:
|
|||||||
|
|
||||||
filterend:
|
filterend:
|
||||||
|
|
||||||
cmdmod.lockmarks = save_lockmarks;
|
cmdmod.cmod_flags = save_cmod_flags;
|
||||||
if (curbuf != old_curbuf) {
|
if (curbuf != old_curbuf) {
|
||||||
no_wait_return--;
|
no_wait_return--;
|
||||||
emsg(_("E135: *Filter* Autocommands must not change current buffer"));
|
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_start = orig_start;
|
||||||
curbuf->b_op_end = orig_end;
|
curbuf->b_op_end = orig_end;
|
||||||
}
|
}
|
||||||
@ -1730,7 +1731,7 @@ int rename_buffer(char *new_fname)
|
|||||||
curbuf->b_flags |= BF_NOTEDITED;
|
curbuf->b_flags |= BF_NOTEDITED;
|
||||||
if (xfname != NULL && *xfname != NUL) {
|
if (xfname != NULL && *xfname != NUL) {
|
||||||
buf = buflist_new((char_u *)fname, (char_u *)xfname, curwin->w_cursor.lnum, 0);
|
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;
|
curwin->w_alt_fnum = buf->b_fnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1866,7 +1867,7 @@ int do_write(exarg_T *eap)
|
|||||||
&& !eap->forceit
|
&& !eap->forceit
|
||||||
&& !eap->append
|
&& !eap->append
|
||||||
&& !p_wa) {
|
&& !p_wa) {
|
||||||
if (p_confirm || cmdmod.confirm) {
|
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
|
||||||
if (vim_dialog_yesno(VIM_QUESTION, NULL,
|
if (vim_dialog_yesno(VIM_QUESTION, NULL,
|
||||||
(char_u *)_("Write partial file?"), 2) != VIM_YES) {
|
(char_u *)_("Write partial file?"), 2) != VIM_YES) {
|
||||||
goto theend;
|
goto theend;
|
||||||
@ -1985,7 +1986,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (p_confirm || cmdmod.confirm) {
|
if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) {
|
||||||
char buff[DIALOG_MSG_SIZE];
|
char buff[DIALOG_MSG_SIZE];
|
||||||
|
|
||||||
dialog_msg((char *)buff, _("Overwrite existing file \"%s\"?"), fname);
|
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);
|
swapname = (char *)makeswapname((char_u *)fname, (char_u *)ffname, curbuf, (char_u *)dir);
|
||||||
xfree(dir);
|
xfree(dir);
|
||||||
if (os_path_exists((char_u *)swapname)) {
|
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];
|
char buff[DIALOG_MSG_SIZE];
|
||||||
|
|
||||||
dialog_msg((char *)buff,
|
dialog_msg((char *)buff,
|
||||||
@ -2142,7 +2143,7 @@ static int check_readonly(int *forceit, buf_T *buf)
|
|||||||
if (!*forceit && (buf->b_p_ro
|
if (!*forceit && (buf->b_p_ro
|
||||||
|| (os_path_exists(buf->b_ffname)
|
|| (os_path_exists(buf->b_ffname)
|
||||||
&& !os_file_is_writable((char *)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];
|
char buff[DIALOG_MSG_SIZE];
|
||||||
|
|
||||||
if (buf->b_p_ro) {
|
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 (other_file) {
|
||||||
if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF))) {
|
if (!(flags & (ECMD_ADDBUF | ECMD_ALTBUF))) {
|
||||||
if (!cmdmod.keepalt) {
|
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
|
||||||
curwin->w_alt_fnum = curbuf->b_fnum;
|
curwin->w_alt_fnum = curbuf->b_fnum;
|
||||||
}
|
}
|
||||||
if (oldwin != NULL) {
|
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)
|
// eap->line2 pointed to the end of the buffer and nothing was appended)
|
||||||
// "end" is set to lnum when something has been appended, otherwise
|
// "end" is set to lnum when something has been appended, otherwise
|
||||||
// it is the same as "start" -- Acevedo
|
// it is the same as "start" -- Acevedo
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
curbuf->b_op_start.lnum
|
curbuf->b_op_start.lnum
|
||||||
= (eap->line2 < curbuf->b_ml.ml_line_count) ? eap->line2 + 1 : curbuf->b_ml.ml_line_count;
|
= (eap->line2 < curbuf->b_ml.ml_line_count) ? eap->line2 + 1 : curbuf->b_ml.ml_line_count;
|
||||||
if (eap->cmdidx != CMD_append) {
|
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 (save) {
|
||||||
if (!cmdmod.keeppatterns) {
|
if ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0) {
|
||||||
save_re_pat(RE_SUBST, (char_u *)pat, p_magic);
|
save_re_pat(RE_SUBST, (char_u *)pat, p_magic);
|
||||||
}
|
}
|
||||||
add_to_history(HIST_SEARCH, (char_u *)pat, true, NUL);
|
add_to_history(HIST_SEARCH, (char_u *)pat, true, NUL);
|
||||||
@ -4373,7 +4374,7 @@ skip:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sub_nsubs > start_nsubs) {
|
if (sub_nsubs > start_nsubs) {
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// Set the '[ and '] marks.
|
// Set the '[ and '] marks.
|
||||||
curbuf->b_op_start.lnum = eap->line1;
|
curbuf->b_op_start.lnum = eap->line1;
|
||||||
curbuf->b_op_end.lnum = line2;
|
curbuf->b_op_end.lnum = line2;
|
||||||
@ -4826,8 +4827,8 @@ void ex_help(exarg_T *eap)
|
|||||||
* Always open a new one for ":tab help".
|
* Always open a new one for ":tab help".
|
||||||
*/
|
*/
|
||||||
if (!bt_help(curwin->w_buffer)
|
if (!bt_help(curwin->w_buffer)
|
||||||
|| cmdmod.tab != 0) {
|
|| cmdmod.cmod_tab != 0) {
|
||||||
if (cmdmod.tab != 0) {
|
if (cmdmod.cmod_tab != 0) {
|
||||||
wp = NULL;
|
wp = NULL;
|
||||||
} else {
|
} else {
|
||||||
wp = NULL;
|
wp = NULL;
|
||||||
@ -4853,7 +4854,7 @@ void ex_help(exarg_T *eap)
|
|||||||
// specified, the current window is vertically split and
|
// specified, the current window is vertically split and
|
||||||
// narrow.
|
// narrow.
|
||||||
n = WSP_HELP;
|
n = WSP_HELP;
|
||||||
if (cmdmod.split == 0 && curwin->w_width != Columns
|
if (cmdmod.cmod_split == 0 && curwin->w_width != Columns
|
||||||
&& curwin->w_width < 80) {
|
&& curwin->w_width < 80) {
|
||||||
n |= WSP_TOP;
|
n |= WSP_TOP;
|
||||||
}
|
}
|
||||||
@ -4873,9 +4874,9 @@ void ex_help(exarg_T *eap)
|
|||||||
alt_fnum = curbuf->b_fnum;
|
alt_fnum = curbuf->b_fnum;
|
||||||
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
|
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
|
||||||
ECMD_HIDE + ECMD_SET_HELP,
|
ECMD_HIDE + ECMD_SET_HELP,
|
||||||
NULL // buffer is still open, don't store info
|
NULL); // buffer is still open, don't store info
|
||||||
);
|
|
||||||
if (!cmdmod.keepalt) {
|
if ((cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
|
||||||
curwin->w_alt_fnum = alt_fnum;
|
curwin->w_alt_fnum = alt_fnum;
|
||||||
}
|
}
|
||||||
empty_fnum = curbuf->b_fnum;
|
empty_fnum = curbuf->b_fnum;
|
||||||
@ -4901,7 +4902,8 @@ void ex_help(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keep the previous alternate file
|
// 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;
|
curwin->w_alt_fnum = alt_fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6069,7 +6071,7 @@ void ex_oldfiles(exarg_T *eap)
|
|||||||
got_int = false;
|
got_int = false;
|
||||||
|
|
||||||
// File selection prompt on ":browse oldfiles"
|
// File selection prompt on ":browse oldfiles"
|
||||||
if (cmdmod.browse) {
|
if (cmdmod.cmod_flags & CMOD_BROWSE) {
|
||||||
quit_more = false;
|
quit_more = false;
|
||||||
nr = prompt_for_number(false);
|
nr = prompt_for_number(false);
|
||||||
msg_starthere();
|
msg_starthere();
|
||||||
@ -6081,7 +6083,7 @@ void ex_oldfiles(exarg_T *eap)
|
|||||||
char *const s = expand_env_save((char *)p);
|
char *const s = expand_env_save((char *)p);
|
||||||
eap->arg = s;
|
eap->arg = s;
|
||||||
eap->cmdidx = CMD_edit;
|
eap->cmdidx = CMD_edit;
|
||||||
cmdmod.browse = false;
|
cmdmod.cmod_flags &= ~CMOD_BROWSE;
|
||||||
do_exedit(eap, NULL);
|
do_exedit(eap, NULL);
|
||||||
xfree(s);
|
xfree(s);
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ bool check_changed(buf_T *buf, int flags)
|
|||||||
&& bufIsChanged(buf)
|
&& bufIsChanged(buf)
|
||||||
&& ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1)
|
&& ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1)
|
||||||
&& (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL)) {
|
&& (!(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;
|
int count = 0;
|
||||||
|
|
||||||
if (flags & CCGD_ALLBUF) {
|
if (flags & CCGD_ALLBUF) {
|
||||||
@ -719,7 +719,7 @@ bool check_changed_any(bool hidden, bool unload)
|
|||||||
ret = true;
|
ret = true;
|
||||||
exiting = false;
|
exiting = false;
|
||||||
// When ":confirm" used, don't give an error message.
|
// 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()
|
// There must be a wait_return for this message, do_buffer()
|
||||||
// may cause a redraw. But wait_return() is a no-op when vgetc()
|
// 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
|
// 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();
|
setpcmark();
|
||||||
|
|
||||||
// split window or create new tab page first
|
// 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) {
|
if (win_split(0, 0) == FAIL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3027,7 +3027,7 @@ void ex_drop(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdmod.tab) {
|
if (cmdmod.cmod_tab) {
|
||||||
// ":tab drop file ...": open a tab for each argument that isn't
|
// ":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
|
// edited in a window yet. It's like ":tab all" but without closing
|
||||||
// windows or tabs.
|
// windows or tabs.
|
||||||
|
@ -243,41 +243,45 @@ struct expand {
|
|||||||
#define XP_BS_ONE 1 // uses one backslash before a space
|
#define XP_BS_ONE 1 // uses one backslash before a space
|
||||||
#define XP_BS_THREE 2 // uses three backslashes 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
|
/// Command modifiers ":vertical", ":browse", ":confirm", ":hide", etc. set a
|
||||||
/// 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 cmod_flags; ///< CMOD_ flags
|
||||||
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
|
|
||||||
regmatch_T filter_regmatch; ///< set by :filter /pat/
|
|
||||||
bool filter_force; ///< set for :filter!
|
|
||||||
|
|
||||||
int cmod_verbose; ///< non-zero to set 'verbose', -1 is used for zero override
|
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; ///< non-zero to set 'verbose', -1 is used for zero override
|
||||||
|
|
||||||
// values for undo_cmdmod()
|
// values for undo_cmdmod()
|
||||||
char_u *cmod_save_ei; ///< saved value of 'eventignore'
|
char_u *cmod_save_ei; ///< saved value of 'eventignore'
|
||||||
int cmod_did_sandbox; ///< set when "sandbox" was incremented
|
int cmod_did_sandbox; ///< set when "sandbox" was incremented
|
||||||
long cmod_verbose_save; ///< if 'verbose' was set: value of p_verbose plus one
|
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_silent; ///< if non-zero: saved value of msg_silent + 1
|
||||||
int cmod_did_esilent; ///< incremented when emsg_silent is
|
int cmod_save_msg_scroll; ///< for restoring msg_scroll
|
||||||
|
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 {
|
||||||
cmdmod_T cmdmod;
|
cmdmod_T cmdmod;
|
||||||
|
@ -1411,7 +1411,6 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
|
|||||||
char *cmd;
|
char *cmd;
|
||||||
char *p;
|
char *p;
|
||||||
char *after_modifier = NULL;
|
char *after_modifier = NULL;
|
||||||
cmdmod_T save_cmdmod = cmdmod;
|
|
||||||
|
|
||||||
// Initialize cmdinfo
|
// Initialize cmdinfo
|
||||||
memset(cmdinfo, 0, sizeof(*cmdinfo));
|
memset(cmdinfo, 0, sizeof(*cmdinfo));
|
||||||
@ -1426,18 +1425,16 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
|
|||||||
eap->cookie = NULL;
|
eap->cookie = NULL;
|
||||||
|
|
||||||
// Parse command modifiers
|
// Parse command modifiers
|
||||||
if (parse_command_modifiers(eap, errormsg, false) == FAIL) {
|
if (parse_command_modifiers(eap, errormsg, &cmdinfo->cmdmod, false) == FAIL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
after_modifier = eap->cmd;
|
after_modifier = eap->cmd;
|
||||||
|
|
||||||
if (cmdmod.cmod_verbose != 0) {
|
if (cmdinfo->cmdmod.cmod_verbose != 0) {
|
||||||
cmdinfo->verbose = cmdmod.cmod_verbose < 0 ? 0 : cmdmod.cmod_verbose;
|
cmdinfo->verbose = cmdinfo->cmdmod.cmod_verbose < 0 ? 0 : cmdinfo->cmdmod.cmod_verbose;
|
||||||
} else {
|
} else {
|
||||||
cmdinfo->verbose = -1;
|
cmdinfo->verbose = -1;
|
||||||
}
|
}
|
||||||
cmdinfo->cmdmod = cmdmod;
|
|
||||||
cmdmod = save_cmdmod;
|
|
||||||
|
|
||||||
// Save location after command modifiers
|
// Save location after command modifiers
|
||||||
cmd = eap->cmd;
|
cmd = eap->cmd;
|
||||||
@ -1673,7 +1670,7 @@ end:
|
|||||||
emsg(errormsg);
|
emsg(errormsg);
|
||||||
}
|
}
|
||||||
// Undo command modifiers
|
// Undo command modifiers
|
||||||
undo_cmdmod(msg_scroll);
|
undo_cmdmod(&cmdmod);
|
||||||
cmdmod = save_cmdmod;
|
cmdmod = save_cmdmod;
|
||||||
return retv;
|
return retv;
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
@ -1704,7 +1701,6 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
|
|||||||
char *errormsg = NULL; // error message
|
char *errormsg = NULL; // error message
|
||||||
char *after_modifier = NULL;
|
char *after_modifier = NULL;
|
||||||
exarg_T ea;
|
exarg_T ea;
|
||||||
const int save_msg_scroll = msg_scroll;
|
|
||||||
cmdmod_T save_cmdmod;
|
cmdmod_T save_cmdmod;
|
||||||
const int save_reg_executing = reg_executing;
|
const int save_reg_executing = reg_executing;
|
||||||
const bool save_pending_end_reg_executing = pending_end_reg_executing;
|
const bool save_pending_end_reg_executing = pending_end_reg_executing;
|
||||||
@ -1746,7 +1742,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
|
|||||||
ea.cookie = cookie;
|
ea.cookie = cookie;
|
||||||
ea.cstack = cstack;
|
ea.cstack = cstack;
|
||||||
|
|
||||||
if (parse_command_modifiers(&ea, &errormsg, false) == FAIL) {
|
if (parse_command_modifiers(&ea, &errormsg, &cmdmod, false) == FAIL) {
|
||||||
goto doend;
|
goto doend;
|
||||||
}
|
}
|
||||||
apply_cmdmod(&cmdmod);
|
apply_cmdmod(&cmdmod);
|
||||||
@ -2361,7 +2357,7 @@ 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(save_msg_scroll);
|
undo_cmdmod(&cmdmod);
|
||||||
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;
|
||||||
@ -2389,25 +2385,25 @@ char *ex_errmsg(const char *const msg, const char *const arg)
|
|||||||
|
|
||||||
/// Parse and skip over command modifiers:
|
/// Parse and skip over command modifiers:
|
||||||
/// - update eap->cmd
|
/// - update eap->cmd
|
||||||
/// - store flags in "cmdmod".
|
/// - store flags in "cmod".
|
||||||
/// - Set ex_pressedreturn for an empty command line.
|
/// - Set ex_pressedreturn for an empty command line.
|
||||||
/// - set msg_silent for ":silent"
|
|
||||||
/// - set 'eventignore' to "all" for ":noautocmd"
|
|
||||||
///
|
///
|
||||||
/// @param skip_only if true, the global variables are not changed, except for
|
/// @param skip_only if false, undo_cmdmod() must be called later to free
|
||||||
/// "cmdmod".
|
/// any cmod_filter_regmatch.regprog.
|
||||||
/// @param[out] errormsg potential error message.
|
/// @param[out] errormsg potential error message.
|
||||||
///
|
///
|
||||||
/// Call apply_cmdmod() to get the side effects of the modifiers:
|
/// Call apply_cmdmod() to get the side effects of the modifiers:
|
||||||
/// - Increment "sandbox" for ":sandbox"
|
/// - Increment "sandbox" for ":sandbox"
|
||||||
/// - set p_verbose for ":verbose"
|
/// - 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.
|
/// @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;
|
char *p;
|
||||||
|
|
||||||
memset(&cmdmod, 0, sizeof(cmdmod));
|
memset(cmod, 0, sizeof(*cmod));
|
||||||
|
|
||||||
// Repeat until no more command modifiers are found.
|
// Repeat until no more command modifiers are found.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -2445,48 +2441,48 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
if (!checkforcmd(&eap->cmd, "aboveleft", 3)) {
|
if (!checkforcmd(&eap->cmd, "aboveleft", 3)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.split |= WSP_ABOVE;
|
cmod->cmod_split |= WSP_ABOVE;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
if (checkforcmd(&eap->cmd, "belowright", 3)) {
|
if (checkforcmd(&eap->cmd, "belowright", 3)) {
|
||||||
cmdmod.split |= WSP_BELOW;
|
cmod->cmod_split |= WSP_BELOW;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkforcmd(&eap->cmd, "browse", 3)) {
|
if (checkforcmd(&eap->cmd, "browse", 3)) {
|
||||||
cmdmod.browse = true;
|
cmod->cmod_flags |= CMOD_BROWSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkforcmd(&eap->cmd, "botright", 2)) {
|
if (!checkforcmd(&eap->cmd, "botright", 2)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.split |= WSP_BOT;
|
cmod->cmod_split |= WSP_BOT;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!checkforcmd(&eap->cmd, "confirm", 4)) {
|
if (!checkforcmd(&eap->cmd, "confirm", 4)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.confirm = true;
|
cmod->cmod_flags |= CMOD_CONFIRM;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
if (checkforcmd(&eap->cmd, "keepmarks", 3)) {
|
if (checkforcmd(&eap->cmd, "keepmarks", 3)) {
|
||||||
cmdmod.keepmarks = true;
|
cmod->cmod_flags |= CMOD_KEEPMARKS;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkforcmd(&eap->cmd, "keepalt", 5)) {
|
if (checkforcmd(&eap->cmd, "keepalt", 5)) {
|
||||||
cmdmod.keepalt = true;
|
cmod->cmod_flags |= CMOD_KEEPALT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkforcmd(&eap->cmd, "keeppatterns", 5)) {
|
if (checkforcmd(&eap->cmd, "keeppatterns", 5)) {
|
||||||
cmdmod.keeppatterns = true;
|
cmod->cmod_flags |= CMOD_KEEPPATTERNS;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkforcmd(&eap->cmd, "keepjumps", 5)) {
|
if (!checkforcmd(&eap->cmd, "keepjumps", 5)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.keepjumps = true;
|
cmod->cmod_flags |= CMOD_KEEPJUMPS;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'f': { // only accept ":filter {pat} cmd"
|
case 'f': { // only accept ":filter {pat} cmd"
|
||||||
@ -2496,7 +2492,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*p == '!') {
|
if (*p == '!') {
|
||||||
cmdmod.filter_force = true;
|
cmod->cmod_filter_force = true;
|
||||||
p = skipwhite(p + 1);
|
p = skipwhite(p + 1);
|
||||||
if (*p == NUL || ends_excmd(*p)) {
|
if (*p == NUL || ends_excmd(*p)) {
|
||||||
break;
|
break;
|
||||||
@ -2512,8 +2508,8 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!skip_only) {
|
if (!skip_only) {
|
||||||
cmdmod.filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
|
cmod->cmod_filter_regmatch.regprog = vim_regcomp(reg_pat, RE_MAGIC);
|
||||||
if (cmdmod.filter_regmatch.regprog == NULL) {
|
if (cmod->cmod_filter_regmatch.regprog == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2528,52 +2524,52 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
eap->cmd = p;
|
eap->cmd = p;
|
||||||
cmdmod.hide = true;
|
cmod->cmod_flags |= CMOD_HIDE;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
if (checkforcmd(&eap->cmd, "lockmarks", 3)) {
|
if (checkforcmd(&eap->cmd, "lockmarks", 3)) {
|
||||||
cmdmod.lockmarks = true;
|
cmod->cmod_flags |= CMOD_LOCKMARKS;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkforcmd(&eap->cmd, "leftabove", 5)) {
|
if (!checkforcmd(&eap->cmd, "leftabove", 5)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.split |= WSP_ABOVE;
|
cmod->cmod_split |= WSP_ABOVE;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
if (checkforcmd(&eap->cmd, "noautocmd", 3)) {
|
if (checkforcmd(&eap->cmd, "noautocmd", 3)) {
|
||||||
cmdmod.cmod_flags |= CMOD_NOAUTOCMD;
|
cmod->cmod_flags |= CMOD_NOAUTOCMD;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkforcmd(&eap->cmd, "noswapfile", 3)) {
|
if (!checkforcmd(&eap->cmd, "noswapfile", 3)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.noswapfile = true;
|
cmod->cmod_flags |= CMOD_NOSWAPFILE;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!checkforcmd(&eap->cmd, "rightbelow", 6)) {
|
if (!checkforcmd(&eap->cmd, "rightbelow", 6)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.split |= WSP_BELOW;
|
cmod->cmod_split |= WSP_BELOW;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (checkforcmd(&eap->cmd, "sandbox", 3)) {
|
if (checkforcmd(&eap->cmd, "sandbox", 3)) {
|
||||||
cmdmod.cmod_flags |= CMOD_SANDBOX;
|
cmod->cmod_flags |= CMOD_SANDBOX;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkforcmd(&eap->cmd, "silent", 3)) {
|
if (!checkforcmd(&eap->cmd, "silent", 3)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.cmod_flags |= CMOD_SILENT;
|
cmod->cmod_flags |= CMOD_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);
|
||||||
cmdmod.cmod_flags |= CMOD_ERRSILENT;
|
cmod->cmod_flags |= CMOD_ERRSILENT;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -2584,13 +2580,13 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
false, 1);
|
false, 1);
|
||||||
|
|
||||||
if (tabnr == MAXLNUM) {
|
if (tabnr == MAXLNUM) {
|
||||||
cmdmod.tab = tabpage_index(curtab) + 1;
|
cmod->cmod_tab = tabpage_index(curtab) + 1;
|
||||||
} else {
|
} else {
|
||||||
if (tabnr < 0 || tabnr > LAST_TAB_NR) {
|
if (tabnr < 0 || tabnr > LAST_TAB_NR) {
|
||||||
*errormsg = _(e_invrange);
|
*errormsg = _(e_invrange);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cmdmod.tab = tabnr + 1;
|
cmod->cmod_tab = tabnr + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eap->cmd = p;
|
eap->cmd = p;
|
||||||
@ -2599,31 +2595,31 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only)
|
|||||||
if (!checkforcmd(&eap->cmd, "topleft", 2)) {
|
if (!checkforcmd(&eap->cmd, "topleft", 2)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.split |= WSP_TOP;
|
cmod->cmod_split |= WSP_TOP;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
if (!checkforcmd(&eap->cmd, "unsilent", 3)) {
|
if (!checkforcmd(&eap->cmd, "unsilent", 3)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmdmod.cmod_flags |= CMOD_UNSILENT;
|
cmod->cmod_flags |= CMOD_UNSILENT;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
if (checkforcmd(&eap->cmd, "vertical", 4)) {
|
if (checkforcmd(&eap->cmd, "vertical", 4)) {
|
||||||
cmdmod.split |= WSP_VERT;
|
cmod->cmod_split |= WSP_VERT;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkforcmd(&p, "verbose", 4)) {
|
if (!checkforcmd(&p, "verbose", 4)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ascii_isdigit(*eap->cmd)) {
|
if (ascii_isdigit(*eap->cmd)) {
|
||||||
cmdmod.cmod_verbose = atoi((char *)eap->cmd);
|
cmod->cmod_verbose = atoi((char *)eap->cmd);
|
||||||
if (cmdmod.cmod_verbose == 0) {
|
if (cmod->cmod_verbose == 0) {
|
||||||
cmdmod.cmod_verbose = -1;
|
cmod->cmod_verbose = -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmdmod.cmod_verbose = 1;
|
cmod->cmod_verbose = 1;
|
||||||
}
|
}
|
||||||
eap->cmd = p;
|
eap->cmd = p;
|
||||||
continue;
|
continue;
|
||||||
@ -2652,6 +2648,7 @@ static void apply_cmdmod(cmdmod_T *cmod)
|
|||||||
if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))
|
if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))
|
||||||
&& cmod->cmod_save_msg_silent == 0) {
|
&& cmod->cmod_save_msg_silent == 0) {
|
||||||
cmod->cmod_save_msg_silent = msg_silent + 1;
|
cmod->cmod_save_msg_silent = msg_silent + 1;
|
||||||
|
cmod->cmod_save_msg_scroll = msg_scroll;
|
||||||
}
|
}
|
||||||
if (cmod->cmod_flags & CMOD_SILENT) {
|
if (cmod->cmod_flags & CMOD_SILENT) {
|
||||||
msg_silent++;
|
msg_silent++;
|
||||||
@ -2665,50 +2662,50 @@ static void apply_cmdmod(cmdmod_T *cmod)
|
|||||||
cmod->cmod_did_esilent++;
|
cmod->cmod_did_esilent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmdmod.cmod_save_ei == NULL) {
|
if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmod->cmod_save_ei == NULL) {
|
||||||
// Set 'eventignore' to "all".
|
// Set 'eventignore' to "all".
|
||||||
// First save the existing option value for restoring it later.
|
// First save the existing option value for restoring it later.
|
||||||
cmdmod.cmod_save_ei = vim_strsave(p_ei);
|
cmod->cmod_save_ei = vim_strsave(p_ei);
|
||||||
set_string_option_direct("ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
|
set_string_option_direct("ei", -1, (char_u *)"all", OPT_FREE, SID_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Undo and free contents of "cmdmod".
|
/// Undo and free contents of "cmod".
|
||||||
static void undo_cmdmod(int save_msg_scroll)
|
static void undo_cmdmod(cmdmod_T *cmod)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
if (cmdmod.cmod_verbose_save > 0) {
|
if (cmod->cmod_verbose_save > 0) {
|
||||||
p_verbose = cmdmod.cmod_verbose_save - 1;
|
p_verbose = cmod->cmod_verbose_save - 1;
|
||||||
cmdmod.cmod_verbose_save = 0;
|
cmod->cmod_verbose_save = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdmod.cmod_did_sandbox) {
|
if (cmod->cmod_did_sandbox) {
|
||||||
sandbox--;
|
sandbox--;
|
||||||
cmdmod.cmod_did_sandbox = false;
|
cmod->cmod_did_sandbox = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdmod.cmod_save_ei != NULL) {
|
if (cmod->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.cmod_save_ei, OPT_FREE, SID_NONE);
|
set_string_option_direct("ei", -1, (char_u *)cmod->cmod_save_ei, OPT_FREE, SID_NONE);
|
||||||
free_string_option((char_u *)cmdmod.cmod_save_ei);
|
free_string_option((char_u *)cmod->cmod_save_ei);
|
||||||
cmdmod.cmod_save_ei = NULL;
|
cmod->cmod_save_ei = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vim_regfree(cmdmod.filter_regmatch.regprog);
|
vim_regfree(cmod->cmod_filter_regmatch.regprog);
|
||||||
|
|
||||||
if (cmdmod.cmod_save_msg_silent > 0) {
|
if (cmod->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 > cmdmod.cmod_save_msg_silent - 1) {
|
if (!did_emsg || msg_silent > cmod->cmod_save_msg_silent - 1) {
|
||||||
msg_silent = cmdmod.cmod_save_msg_silent - 1;
|
msg_silent = cmod->cmod_save_msg_silent - 1;
|
||||||
}
|
}
|
||||||
emsg_silent -= cmdmod.cmod_did_esilent;
|
emsg_silent -= cmod->cmod_did_esilent;
|
||||||
if (emsg_silent < 0) {
|
if (emsg_silent < 0) {
|
||||||
emsg_silent = 0;
|
emsg_silent = 0;
|
||||||
}
|
}
|
||||||
// Restore msg_scroll, it's set by file I/O commands, even when no
|
// Restore msg_scroll, it's set by file I/O commands, even when no
|
||||||
// message is actually displayed.
|
// 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
|
// "silent reg" or "silent echo x" inside "redir" leaves msg_col
|
||||||
// somewhere in the line. Put it back in the first column.
|
// somewhere in the line. Put it back in the first column.
|
||||||
@ -2716,8 +2713,8 @@ static void undo_cmdmod(int save_msg_scroll)
|
|||||||
msg_col = 0;
|
msg_col = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdmod.cmod_save_msg_silent = 0;
|
cmod->cmod_save_msg_silent = 0;
|
||||||
cmdmod.cmod_did_esilent = 0;
|
cmod->cmod_did_esilent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5467,7 +5464,7 @@ static int check_more(int message, bool forceit)
|
|||||||
if (!forceit && only_one_window()
|
if (!forceit && only_one_window()
|
||||||
&& ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) {
|
&& ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) {
|
||||||
if (message) {
|
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];
|
char buff[DIALOG_MSG_SIZE];
|
||||||
|
|
||||||
vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
|
vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
|
||||||
@ -6534,8 +6531,8 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add modifiers from "cmdmod.split" to "buf". Set "multi_mods" when one was
|
/// Add modifiers from "cmdmod.cmod_split" to "buf". Set "multi_mods" when one
|
||||||
/// added.
|
/// was added.
|
||||||
///
|
///
|
||||||
/// @return the number of bytes added
|
/// @return the number of bytes added
|
||||||
size_t add_win_cmd_modifers(char *buf, bool *multi_mods)
|
size_t add_win_cmd_modifers(char *buf, bool *multi_mods)
|
||||||
@ -6543,28 +6540,28 @@ size_t add_win_cmd_modifers(char *buf, bool *multi_mods)
|
|||||||
size_t result = 0;
|
size_t result = 0;
|
||||||
|
|
||||||
// :aboveleft and :leftabove
|
// :aboveleft and :leftabove
|
||||||
if (cmdmod.split & WSP_ABOVE) {
|
if (cmdmod.cmod_split & WSP_ABOVE) {
|
||||||
result += add_cmd_modifier(buf, "aboveleft", multi_mods);
|
result += add_cmd_modifier(buf, "aboveleft", multi_mods);
|
||||||
}
|
}
|
||||||
// :belowright and :rightbelow
|
// :belowright and :rightbelow
|
||||||
if (cmdmod.split & WSP_BELOW) {
|
if (cmdmod.cmod_split & WSP_BELOW) {
|
||||||
result += add_cmd_modifier(buf, "belowright", multi_mods);
|
result += add_cmd_modifier(buf, "belowright", multi_mods);
|
||||||
}
|
}
|
||||||
// :botright
|
// :botright
|
||||||
if (cmdmod.split & WSP_BOT) {
|
if (cmdmod.cmod_split & WSP_BOT) {
|
||||||
result += add_cmd_modifier(buf, "botright", multi_mods);
|
result += add_cmd_modifier(buf, "botright", multi_mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
// :tab
|
// :tab
|
||||||
if (cmdmod.tab > 0) {
|
if (cmdmod.cmod_tab > 0) {
|
||||||
result += add_cmd_modifier(buf, "tab", multi_mods);
|
result += add_cmd_modifier(buf, "tab", multi_mods);
|
||||||
}
|
}
|
||||||
// :topleft
|
// :topleft
|
||||||
if (cmdmod.split & WSP_TOP) {
|
if (cmdmod.cmod_split & WSP_TOP) {
|
||||||
result += add_cmd_modifier(buf, "topleft", multi_mods);
|
result += add_cmd_modifier(buf, "topleft", multi_mods);
|
||||||
}
|
}
|
||||||
// :vertical
|
// :vertical
|
||||||
if (cmdmod.split & WSP_VERT) {
|
if (cmdmod.cmod_split & WSP_VERT) {
|
||||||
result += add_cmd_modifier(buf, "vertical", multi_mods);
|
result += add_cmd_modifier(buf, "vertical", multi_mods);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -6576,23 +6573,23 @@ size_t uc_mods(char *buf)
|
|||||||
bool multi_mods = false;
|
bool multi_mods = false;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool *set;
|
int flag;
|
||||||
char *name;
|
char *name;
|
||||||
} mod_entry_T;
|
} mod_entry_T;
|
||||||
static mod_entry_T mod_entries[] = {
|
static mod_entry_T mod_entries[] = {
|
||||||
{ &cmdmod.browse, "browse" },
|
{ CMOD_BROWSE, "browse" },
|
||||||
{ &cmdmod.confirm, "confirm" },
|
{ CMOD_CONFIRM, "confirm" },
|
||||||
{ &cmdmod.hide, "hide" },
|
{ CMOD_HIDE, "hide" },
|
||||||
{ &cmdmod.keepalt, "keepalt" },
|
{ CMOD_KEEPALT, "keepalt" },
|
||||||
{ &cmdmod.keepjumps, "keepjumps" },
|
{ CMOD_KEEPJUMPS, "keepjumps" },
|
||||||
{ &cmdmod.keepmarks, "keepmarks" },
|
{ CMOD_KEEPMARKS, "keepmarks" },
|
||||||
{ &cmdmod.keeppatterns, "keeppatterns" },
|
{ CMOD_KEEPPATTERNS, "keeppatterns" },
|
||||||
{ &cmdmod.lockmarks, "lockmarks" },
|
{ CMOD_LOCKMARKS, "lockmarks" },
|
||||||
{ &cmdmod.noswapfile, "noswapfile" }
|
{ CMOD_NOSWAPFILE, "noswapfile" }
|
||||||
};
|
};
|
||||||
// the modifiers that are simple flags
|
// the modifiers that are simple flags
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(mod_entries); i++) {
|
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);
|
result += add_cmd_modifier(buf, mod_entries[i].name, &multi_mods);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6611,7 +6608,7 @@ size_t uc_mods(char *buf)
|
|||||||
if (p_verbose > 0) {
|
if (p_verbose > 0) {
|
||||||
result += add_cmd_modifier(buf, "verbose", &multi_mods);
|
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);
|
result += add_win_cmd_modifers(buf, &multi_mods);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -7159,7 +7156,7 @@ void ex_win_close(int forceit, win_T *win, tabpage_T *tp)
|
|||||||
|
|
||||||
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
|
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
|
||||||
if (need_hide && !buf_hide(buf) && !forceit) {
|
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;
|
bufref_T bufref;
|
||||||
set_bufref(&bufref, buf);
|
set_bufref(&bufref, buf);
|
||||||
dialog_changed(buf, false);
|
dialog_changed(buf, false);
|
||||||
@ -7642,7 +7639,7 @@ void ex_splitview(exarg_T *eap)
|
|||||||
|
|
||||||
// A ":split" in the quickfix window works like ":new". Don't want two
|
// A ":split" in the quickfix window works like ":new". Don't want two
|
||||||
// quickfix windows. But it's OK when doing ":tab split".
|
// 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) {
|
if (eap->cmdidx == CMD_split) {
|
||||||
eap->cmdidx = CMD_new;
|
eap->cmdidx = CMD_new;
|
||||||
}
|
}
|
||||||
@ -7664,7 +7661,7 @@ void ex_splitview(exarg_T *eap)
|
|||||||
* Either open new tab page or split the window.
|
* Either open new tab page or split the window.
|
||||||
*/
|
*/
|
||||||
if (use_tab) {
|
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) {
|
? 0 : (int)eap->line2 + 1, (char_u *)eap->arg) != FAIL) {
|
||||||
do_exedit(eap, old_curwin);
|
do_exedit(eap, old_curwin);
|
||||||
apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, false, curbuf);
|
apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, false, curbuf);
|
||||||
@ -7673,7 +7670,7 @@ void ex_splitview(exarg_T *eap)
|
|||||||
if (curwin != old_curwin
|
if (curwin != old_curwin
|
||||||
&& win_valid(old_curwin)
|
&& win_valid(old_curwin)
|
||||||
&& old_curwin->w_buffer != curbuf
|
&& old_curwin->w_buffer != curbuf
|
||||||
&& !cmdmod.keepalt) {
|
&& (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
|
||||||
old_curwin->w_alt_fnum = curbuf->b_fnum;
|
old_curwin->w_alt_fnum = curbuf->b_fnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7831,7 +7828,7 @@ static void ex_resize(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
n = (int)atol(eap->arg);
|
n = (int)atol(eap->arg);
|
||||||
if (cmdmod.split & WSP_VERT) {
|
if (cmdmod.cmod_split & WSP_VERT) {
|
||||||
if (*eap->arg == '-' || *eap->arg == '+') {
|
if (*eap->arg == '-' || *eap->arg == '+') {
|
||||||
n += wp->w_width;
|
n += wp->w_width;
|
||||||
} else if (n == 0 && eap->arg[0] == NUL) { // default is very wide
|
} else if (n == 0 && eap->arg[0] == NUL) { // default is very wide
|
||||||
@ -8002,7 +7999,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
|
|||||||
&& curwin != old_curwin
|
&& curwin != old_curwin
|
||||||
&& win_valid(old_curwin)
|
&& win_valid(old_curwin)
|
||||||
&& old_curwin->w_buffer != curbuf
|
&& old_curwin->w_buffer != curbuf
|
||||||
&& !cmdmod.keepalt) {
|
&& (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) {
|
||||||
old_curwin->w_alt_fnum = curbuf->b_fnum;
|
old_curwin->w_alt_fnum = curbuf->b_fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8452,8 +8449,8 @@ static void ex_wincmd(exarg_T *eap)
|
|||||||
emsg(_(e_invarg));
|
emsg(_(e_invarg));
|
||||||
} else if (!eap->skip) {
|
} else if (!eap->skip) {
|
||||||
// Pass flags on for ":vertical wincmd ]".
|
// Pass flags on for ":vertical wincmd ]".
|
||||||
postponed_split_flags = cmdmod.split;
|
postponed_split_flags = cmdmod.cmod_split;
|
||||||
postponed_split_tab = cmdmod.tab;
|
postponed_split_tab = cmdmod.cmod_tab;
|
||||||
do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar);
|
do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar);
|
||||||
postponed_split_flags = 0;
|
postponed_split_flags = 0;
|
||||||
postponed_split_tab = 0;
|
postponed_split_tab = 0;
|
||||||
@ -9289,8 +9286,8 @@ static void ex_pedit(exarg_T *eap)
|
|||||||
static void ex_stag(exarg_T *eap)
|
static void ex_stag(exarg_T *eap)
|
||||||
{
|
{
|
||||||
postponed_split = -1;
|
postponed_split = -1;
|
||||||
postponed_split_flags = cmdmod.split;
|
postponed_split_flags = cmdmod.cmod_split;
|
||||||
postponed_split_tab = cmdmod.tab;
|
postponed_split_tab = cmdmod.cmod_tab;
|
||||||
ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
|
ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
|
||||||
postponed_split_flags = 0;
|
postponed_split_flags = 0;
|
||||||
postponed_split_tab = 0;
|
postponed_split_tab = 0;
|
||||||
|
@ -309,7 +309,6 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
|||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char *cmd;
|
char *cmd;
|
||||||
cmdmod_T save_cmdmod = cmdmod;
|
|
||||||
char *p;
|
char *p;
|
||||||
bool delim_optional = false;
|
bool delim_optional = false;
|
||||||
int delim;
|
int delim;
|
||||||
@ -346,8 +345,8 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
|||||||
ea.cmd = (char *)ccline.cmdbuff;
|
ea.cmd = (char *)ccline.cmdbuff;
|
||||||
ea.addr_type = ADDR_LINES;
|
ea.addr_type = ADDR_LINES;
|
||||||
|
|
||||||
parse_command_modifiers(&ea, &dummy, true);
|
cmdmod_T dummy_cmdmod;
|
||||||
cmdmod = save_cmdmod;
|
parse_command_modifiers(&ea, &dummy, &dummy_cmdmod, true);
|
||||||
|
|
||||||
cmd = skip_range(ea.cmd, NULL);
|
cmd = skip_range(ea.cmd, NULL);
|
||||||
if (vim_strchr("sgvl", *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_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
|
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
|
p_hls = false; // Don't show search highlighting during live substitution
|
||||||
cmdmod.split = 0; // Disable :leftabove/botright modifiers
|
cmdmod.cmod_split = 0; // Disable :leftabove/botright modifiers
|
||||||
cmdmod.tab = 0; // Disable :tab modifier
|
cmdmod.cmod_tab = 0; // Disable :tab modifier
|
||||||
cmdmod.noswapfile = true; // Disable swap for preview buffer
|
cmdmod.cmod_flags |= CMOD_NOSWAPFILE; // Disable swap for preview buffer
|
||||||
|
|
||||||
// Open preview buffer if inccommand=split.
|
// Open preview buffer if inccommand=split.
|
||||||
if (!icm_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);
|
assert(histype != HIST_DEFAULT);
|
||||||
|
|
||||||
if (cmdmod.keeppatterns && histype == HIST_SEARCH) {
|
if ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) && histype == HIST_SEARCH) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6604,8 +6603,8 @@ static int open_cmdwin(void)
|
|||||||
pum_undisplay(true);
|
pum_undisplay(true);
|
||||||
|
|
||||||
// don't use a new tab page
|
// don't use a new tab page
|
||||||
cmdmod.tab = 0;
|
cmdmod.cmod_tab = 0;
|
||||||
cmdmod.noswapfile = 1;
|
cmdmod.cmod_flags |= CMOD_NOSWAPFILE;
|
||||||
|
|
||||||
// Create a window for the command-line buffer.
|
// Create a window for the command-line buffer.
|
||||||
if (win_split((int)p_cwh, WSP_BOT) == FAIL) {
|
if (win_split((int)p_cwh, WSP_BOT) == FAIL) {
|
||||||
|
@ -1890,7 +1890,7 @@ failed:
|
|||||||
check_cursor_lnum();
|
check_cursor_lnum();
|
||||||
beginline(BL_WHITE | BL_FIX); // on first non-blank
|
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.
|
// Set '[ and '] marks to the newly read lines.
|
||||||
curbuf->b_op_start.lnum = from + 1;
|
curbuf->b_op_start.lnum = from + 1;
|
||||||
curbuf->b_op_start.col = 0;
|
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)
|
if (buf == NULL || (buf->b_ml.ml_mfp == NULL && !empty_memline)
|
||||||
|| did_cmd || nofile_err
|
|| did_cmd || nofile_err
|
||||||
|| aborting()) {
|
|| aborting()) {
|
||||||
if (buf != NULL && cmdmod.lockmarks) {
|
if (buf != NULL && (cmdmod.cmod_flags & CMOD_LOCKMARKS)) {
|
||||||
// restore the original '[ and '] positions
|
// restore the original '[ and '] positions
|
||||||
buf->b_op_start = orig_start;
|
buf->b_op_start = orig_start;
|
||||||
buf->b_op_end = orig_end;
|
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
|
// restore the original '[ and '] positions
|
||||||
buf->b_op_start = orig_start;
|
buf->b_op_start = orig_start;
|
||||||
buf->b_op_end = orig_end;
|
buf->b_op_end = orig_end;
|
||||||
|
@ -187,8 +187,8 @@ static void do_cscope_general(exarg_T *eap, int make_split)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
postponed_split = -1;
|
postponed_split = -1;
|
||||||
postponed_split_flags = cmdmod.split;
|
postponed_split_flags = cmdmod.cmod_split;
|
||||||
postponed_split_tab = cmdmod.tab;
|
postponed_split_tab = cmdmod.cmod_tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdp->func(eap);
|
cmdp->func(eap);
|
||||||
|
@ -1917,7 +1917,7 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
|
|||||||
|
|
||||||
lua_newtable(lstate); // smods table
|
lua_newtable(lstate); // smods table
|
||||||
|
|
||||||
lua_pushinteger(lstate, cmdmod.tab);
|
lua_pushinteger(lstate, cmdmod.cmod_tab);
|
||||||
lua_setfield(lstate, -2, "tab");
|
lua_setfield(lstate, -2, "tab");
|
||||||
|
|
||||||
lua_pushinteger(lstate, (cmdmod.cmod_verbose != 0
|
lua_pushinteger(lstate, (cmdmod.cmod_verbose != 0
|
||||||
@ -1925,20 +1925,20 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
|
|||||||
: -1));
|
: -1));
|
||||||
lua_setfield(lstate, -2, "verbose");
|
lua_setfield(lstate, -2, "verbose");
|
||||||
|
|
||||||
if (cmdmod.split & WSP_ABOVE) {
|
if (cmdmod.cmod_split & WSP_ABOVE) {
|
||||||
lua_pushstring(lstate, "aboveleft");
|
lua_pushstring(lstate, "aboveleft");
|
||||||
} else if (cmdmod.split & WSP_BELOW) {
|
} else if (cmdmod.cmod_split & WSP_BELOW) {
|
||||||
lua_pushstring(lstate, "belowright");
|
lua_pushstring(lstate, "belowright");
|
||||||
} else if (cmdmod.split & WSP_TOP) {
|
} else if (cmdmod.cmod_split & WSP_TOP) {
|
||||||
lua_pushstring(lstate, "topleft");
|
lua_pushstring(lstate, "topleft");
|
||||||
} else if (cmdmod.split & WSP_BOT) {
|
} else if (cmdmod.cmod_split & WSP_BOT) {
|
||||||
lua_pushstring(lstate, "botright");
|
lua_pushstring(lstate, "botright");
|
||||||
} else {
|
} else {
|
||||||
lua_pushstring(lstate, "");
|
lua_pushstring(lstate, "");
|
||||||
}
|
}
|
||||||
lua_setfield(lstate, -2, "split");
|
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_setfield(lstate, -2, "vertical");
|
||||||
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_SILENT);
|
lua_pushboolean(lstate, cmdmod.cmod_flags & CMOD_SILENT);
|
||||||
lua_setfield(lstate, -2, "silent");
|
lua_setfield(lstate, -2, "silent");
|
||||||
@ -1950,24 +1950,24 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
|
|||||||
lua_setfield(lstate, -2, "noautocmd");
|
lua_setfield(lstate, -2, "noautocmd");
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool *set;
|
int flag;
|
||||||
char *name;
|
char *name;
|
||||||
} mod_entry_T;
|
} mod_entry_T;
|
||||||
static mod_entry_T mod_entries[] = {
|
static mod_entry_T mod_entries[] = {
|
||||||
{ &cmdmod.browse, "browse" },
|
{ CMOD_BROWSE, "browse" },
|
||||||
{ &cmdmod.confirm, "confirm" },
|
{ CMOD_CONFIRM, "confirm" },
|
||||||
{ &cmdmod.hide, "hide" },
|
{ CMOD_HIDE, "hide" },
|
||||||
{ &cmdmod.keepalt, "keepalt" },
|
{ CMOD_KEEPALT, "keepalt" },
|
||||||
{ &cmdmod.keepjumps, "keepjumps" },
|
{ CMOD_KEEPJUMPS, "keepjumps" },
|
||||||
{ &cmdmod.keepmarks, "keepmarks" },
|
{ CMOD_KEEPMARKS, "keepmarks" },
|
||||||
{ &cmdmod.keeppatterns, "keeppatterns" },
|
{ CMOD_KEEPPATTERNS, "keeppatterns" },
|
||||||
{ &cmdmod.lockmarks, "lockmarks" },
|
{ CMOD_LOCKMARKS, "lockmarks" },
|
||||||
{ &cmdmod.noswapfile, "noswapfile" }
|
{ CMOD_NOSWAPFILE, "noswapfile" }
|
||||||
};
|
};
|
||||||
|
|
||||||
// The modifiers that are simple flags
|
// The modifiers that are simple flags
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(mod_entries); i++) {
|
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);
|
lua_setfield(lstate, -2, mod_entries[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void setpcmark(void)
|
|||||||
xfmark_T *fm;
|
xfmark_T *fm;
|
||||||
|
|
||||||
// for :global the mark is set only once
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,7 +990,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, linenr_T amount
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// named marks, lower case and upper case
|
// named marks, lower case and upper case
|
||||||
for (i = 0; i < NMARKS; i++) {
|
for (i = 0; i < NMARKS; i++) {
|
||||||
ONE_ADJUST(&(curbuf->b_namedm[i].mark.lnum));
|
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.
|
* Adjust items in all windows related to the current buffer.
|
||||||
*/
|
*/
|
||||||
FOR_ALL_TAB_WINDOWS(tab, win) {
|
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
|
// Marks in the jumplist. When deleting lines, this may create
|
||||||
// duplicate marks in the jumplist, they will be removed later.
|
// duplicate marks in the jumplist, they will be removed later.
|
||||||
for (i = 0; i < win->w_jumplistlen; i++) {
|
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 (win->w_buffer == curbuf) {
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// marks in the tag stack
|
// marks in the tag stack
|
||||||
for (i = 0; i < win->w_tagstacklen; i++) {
|
for (i = 0; i < win->w_tagstacklen; i++) {
|
||||||
if (win->w_tagstack[i].fmark.fnum == fnum) {
|
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;
|
int fnum = curbuf->b_fnum;
|
||||||
pos_T *posp;
|
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
|
return; // nothing to do
|
||||||
}
|
}
|
||||||
// named marks, lower case and upper case
|
// named marks, lower case and upper case
|
||||||
|
@ -264,7 +264,7 @@ int ml_open(buf_T *buf)
|
|||||||
buf->b_ml.ml_chunksize = NULL;
|
buf->b_ml.ml_chunksize = NULL;
|
||||||
buf->b_ml.ml_usedchunks = 0;
|
buf->b_ml.ml_usedchunks = 0;
|
||||||
|
|
||||||
if (cmdmod.noswapfile) {
|
if (cmdmod.cmod_flags & CMOD_NOSWAPFILE) {
|
||||||
buf->b_p_swf = false;
|
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.
|
* When 'updatecount' is 0 and 'noswapfile' there is no swap file.
|
||||||
* For help files we will make a swap file now.
|
* 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
|
ml_open_file(buf); // create a swap file
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -475,7 +475,8 @@ void ml_open_file(buf_T *buf)
|
|||||||
char_u *dirp;
|
char_u *dirp;
|
||||||
|
|
||||||
mfp = buf->b_ml.ml_mfp;
|
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) {
|
|| buf->terminal) {
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
}
|
}
|
||||||
|
@ -2324,12 +2324,12 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
|
|||||||
/// "pattern".
|
/// "pattern".
|
||||||
bool message_filtered(char_u *msg)
|
bool message_filtered(char_u *msg)
|
||||||
{
|
{
|
||||||
if (cmdmod.filter_regmatch.regprog == NULL) {
|
if (cmdmod.cmod_filter_regmatch.regprog == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool match = vim_regexec(&cmdmod.filter_regmatch, msg, (colnr_T)0);
|
bool match = vim_regexec(&cmdmod.cmod_filter_regmatch, msg, (colnr_T)0);
|
||||||
return cmdmod.filter_force ? match : !match;
|
return cmdmod.cmod_filter_force ? match : !match;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// including horizontal separator
|
/// including horizontal separator
|
||||||
|
@ -268,7 +268,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount)
|
|||||||
msg_attr_keep((char *)IObuff, 0, true, false);
|
msg_attr_keep((char *)IObuff, 0, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// Set "'[" and "']" marks.
|
// Set "'[" and "']" marks.
|
||||||
curbuf->b_op_start = oap->start;
|
curbuf->b_op_start = oap->start;
|
||||||
curbuf->b_op_end.lnum = oap->end.lnum;
|
curbuf->b_op_end.lnum = oap->end.lnum;
|
||||||
@ -693,7 +693,7 @@ void op_reindent(oparg_T *oap, Indenter how)
|
|||||||
"%" PRId64 " lines indented ", i),
|
"%" PRId64 " lines indented ", i),
|
||||||
(int64_t)i);
|
(int64_t)i);
|
||||||
}
|
}
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// set '[ and '] marks
|
// set '[ and '] marks
|
||||||
curbuf->b_op_start = oap->start;
|
curbuf->b_op_start = oap->start;
|
||||||
curbuf->b_op_end = oap->end;
|
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);
|
msgmore(curbuf->b_ml.ml_line_count - old_lcount);
|
||||||
|
|
||||||
setmarks:
|
setmarks:
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
if (oap->motion_type == kMTBlockWise) {
|
if (oap->motion_type == kMTBlockWise) {
|
||||||
curbuf->b_op_end.lnum = oap->end.lnum;
|
curbuf->b_op_end.lnum = oap->end.lnum;
|
||||||
curbuf->b_op_end.col = oap->start.col;
|
curbuf->b_op_end.col = oap->start.col;
|
||||||
@ -2063,7 +2063,7 @@ static int op_replace(oparg_T *oap, int c)
|
|||||||
check_cursor();
|
check_cursor();
|
||||||
changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1, 0L, true);
|
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.
|
// Set "'[" and "']" marks.
|
||||||
curbuf->b_op_start = oap->start;
|
curbuf->b_op_start = oap->start;
|
||||||
curbuf->b_op_end = oap->end;
|
curbuf->b_op_end = oap->end;
|
||||||
@ -2133,7 +2133,7 @@ void op_tilde(oparg_T *oap)
|
|||||||
redraw_curbuf_later(INVERTED);
|
redraw_curbuf_later(INVERTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// Set '[ and '] marks.
|
// Set '[ and '] marks.
|
||||||
curbuf->b_op_start = oap->start;
|
curbuf->b_op_start = oap->start;
|
||||||
curbuf->b_op_end = oap->end;
|
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.
|
// Set "'[" and "']" marks.
|
||||||
curbuf->b_op_start = oap->start;
|
curbuf->b_op_start = oap->start;
|
||||||
curbuf->b_op_end = oap->end;
|
curbuf->b_op_end = oap->end;
|
||||||
@ -3708,7 +3708,7 @@ error:
|
|||||||
curwin->w_set_curswant = TRUE;
|
curwin->w_set_curswant = TRUE;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (cmdmod.lockmarks) {
|
if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
|
||||||
curbuf->b_op_start = orig_start;
|
curbuf->b_op_start = orig_start;
|
||||||
curbuf->b_op_end = orig_end;
|
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
|
// and setup the array of space strings lengths
|
||||||
for (t = 0; t < (linenr_T)count; t++) {
|
for (t = 0; t < (linenr_T)count; t++) {
|
||||||
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + 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.
|
// Set the '[ mark.
|
||||||
curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum;
|
curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum;
|
||||||
curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr);
|
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);
|
ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
|
||||||
|
|
||||||
if (setmark && !cmdmod.lockmarks) {
|
if (setmark && (cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// Set the '] mark.
|
// Set the '] mark.
|
||||||
curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum;
|
curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum;
|
||||||
curwin->w_buffer->b_op_end.col = sumsize;
|
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);
|
redraw_curbuf_later(INVERTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmdmod.lockmarks) {
|
if ((cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0) {
|
||||||
// Set '[ mark at the start of the formatted area
|
// Set '[ mark at the start of the formatted area
|
||||||
curbuf->b_op_start = oap->start;
|
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;
|
old_line_count = curbuf->b_ml.ml_line_count - old_line_count;
|
||||||
msgmore(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
|
// put '] mark on the end of the formatted area
|
||||||
curbuf->b_op_end = curwin->w_cursor;
|
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
|
// Set '[ mark if something changed. Keep the last end
|
||||||
// position from do_addsub().
|
// 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;
|
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
|
// set the '[ and '] marks
|
||||||
curbuf->b_op_start = startpos;
|
curbuf->b_op_start = startpos;
|
||||||
curbuf->b_op_end = endpos;
|
curbuf->b_op_end = endpos;
|
||||||
@ -6155,7 +6155,7 @@ static void op_function(const oparg_T *oap)
|
|||||||
|
|
||||||
virtual_op = save_virtual_op;
|
virtual_op = save_virtual_op;
|
||||||
finish_op = save_finish_op;
|
finish_op = save_finish_op;
|
||||||
if (cmdmod.lockmarks) {
|
if (cmdmod.cmod_flags & CMOD_LOCKMARKS) {
|
||||||
curbuf->b_op_start = orig_start;
|
curbuf->b_op_start = orig_start;
|
||||||
curbuf->b_op_end = orig_end;
|
curbuf->b_op_end = orig_end;
|
||||||
}
|
}
|
||||||
|
@ -6515,7 +6515,7 @@ void buf_copy_options(buf_T *buf, int flags)
|
|||||||
buf->b_p_ml_nobin = p_ml_nobin;
|
buf->b_p_ml_nobin = p_ml_nobin;
|
||||||
buf->b_p_inf = p_inf;
|
buf->b_p_inf = p_inf;
|
||||||
COPY_OPT_SCTX(buf, BV_INF);
|
COPY_OPT_SCTX(buf, BV_INF);
|
||||||
if (cmdmod.noswapfile) {
|
if (cmdmod.cmod_flags & CMOD_NOSWAPFILE) {
|
||||||
buf->b_p_swf = false;
|
buf->b_p_swf = false;
|
||||||
} else {
|
} else {
|
||||||
buf->b_p_swf = p_swf;
|
buf->b_p_swf = p_swf;
|
||||||
|
@ -2493,7 +2493,7 @@ static int jump_to_help_window(qf_info_T *qi, bool newwin, int *opened_window)
|
|||||||
{
|
{
|
||||||
win_T *wp = NULL;
|
win_T *wp = NULL;
|
||||||
|
|
||||||
if (cmdmod.tab != 0 || newwin) {
|
if (cmdmod.cmod_tab != 0 || newwin) {
|
||||||
wp = NULL;
|
wp = NULL;
|
||||||
} else {
|
} else {
|
||||||
wp = qf_find_help_win();
|
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
|
// Split off help window; put it at far top if no position
|
||||||
// specified, the current window is vertically split and narrow.
|
// specified, the current window is vertically split and narrow.
|
||||||
int flags = WSP_HELP;
|
int flags = WSP_HELP;
|
||||||
if (cmdmod.split == 0
|
if (cmdmod.cmod_split == 0
|
||||||
&& curwin->w_width != Columns
|
&& curwin->w_width != Columns
|
||||||
&& curwin->w_width < 80) {
|
&& curwin->w_width < 80) {
|
||||||
flags |= WSP_TOP;
|
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;
|
qfltype_T qfl_type = qfl->qfl_type;
|
||||||
|
|
||||||
// For ":helpgrep" find a help window or open one.
|
// 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) {
|
if (jump_to_help_window(qi, newwin, opened_window) == FAIL) {
|
||||||
return 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.
|
// The current window becomes the previous window afterwards.
|
||||||
win_T *const win = curwin;
|
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
|
// Create the new quickfix window at the very bottom, except when
|
||||||
// :belowright or :aboveleft is used.
|
// :belowright or :aboveleft is used.
|
||||||
win_goto(lastwin);
|
win_goto(lastwin);
|
||||||
}
|
}
|
||||||
// Default is to open the window below the current window
|
// Default is to open the window below the current window
|
||||||
if (cmdmod.split == 0) {
|
if (cmdmod.cmod_split == 0) {
|
||||||
flags = WSP_BELOW;
|
flags = WSP_BELOW;
|
||||||
}
|
}
|
||||||
flags |= WSP_NEWLOC;
|
flags |= WSP_NEWLOC;
|
||||||
@ -3747,9 +3747,9 @@ void ex_copen(exarg_T *eap)
|
|||||||
reset_VIsual_and_resel(); // stop Visual mode
|
reset_VIsual_and_resel(); // stop Visual mode
|
||||||
|
|
||||||
// Find an existing quickfix window, or open a new one.
|
// 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,
|
status = qf_goto_cwindow(qi, eap->addr_count != 0, height,
|
||||||
cmdmod.split & WSP_VERT);
|
cmdmod.cmod_split & WSP_VERT);
|
||||||
}
|
}
|
||||||
if (status == FAIL) {
|
if (status == FAIL) {
|
||||||
if (qf_open_new_cwindow(qi, height) == 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.
|
// with the same name.
|
||||||
wipe_dummy_buffer(buf, dirname_start);
|
wipe_dummy_buffer(buf, dirname_start);
|
||||||
buf = NULL;
|
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] == 'u' // "unload"
|
||||||
|| buf->b_p_bh[0] == 'w' // "wipe"
|
|| buf->b_p_bh[0] == 'w' // "wipe"
|
||||||
|| buf->b_p_bh[0] == 'd') { // "delete"
|
|| buf->b_p_bh[0] == 'd') { // "delete"
|
||||||
|
@ -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,
|
* Save the currently used pattern in the appropriate place,
|
||||||
* unless the pattern should not be remembered.
|
* 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
|
// search or global command
|
||||||
if (pat_save == RE_SEARCH || pat_save == RE_BOTH) {
|
if (pat_save == RE_SEARCH || pat_save == RE_BOTH) {
|
||||||
save_re_pat(RE_SEARCH, pat, magic);
|
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;
|
curwin->w_set_curswant = TRUE;
|
||||||
|
|
||||||
end_do_search:
|
end_do_search:
|
||||||
if ((options & SEARCH_KEEP) || cmdmod.keeppatterns) {
|
if ((options & SEARCH_KEEP) || (cmdmod.cmod_flags & CMOD_KEEPPATTERNS)) {
|
||||||
spats[0].off = old_off;
|
spats[0].off = old_off;
|
||||||
}
|
}
|
||||||
xfree(msgbuf);
|
xfree(msgbuf);
|
||||||
|
@ -2772,7 +2772,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getfile_result == GETFILE_UNUSED
|
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,
|
if (win_split(postponed_split > 0 ? postponed_split : 0,
|
||||||
postponed_split_flags) == FAIL) {
|
postponed_split_flags) == FAIL) {
|
||||||
RedrawingDisabled--;
|
RedrawingDisabled--;
|
||||||
|
@ -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
|
||||||
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;
|
nchar = xchar;
|
||||||
goto wingotofile;
|
goto wingotofile;
|
||||||
case 't': // CTRL-W gt: go to next tab page
|
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".
|
// Add flags from ":vertical", ":topleft" and ":botright".
|
||||||
flags |= cmdmod.split;
|
flags |= cmdmod.cmod_split;
|
||||||
if ((flags & WSP_TOP) && (flags & WSP_BOT)) {
|
if ((flags & WSP_TOP) && (flags & WSP_BOT)) {
|
||||||
emsg(_("E442: Can't split topleft and botright at the same time"));
|
emsg(_("E442: Can't split topleft and botright at the same time"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -3882,7 +3882,7 @@ void close_others(int message, int forceit)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!r) {
|
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);
|
dialog_changed(wp->w_buffer, false);
|
||||||
if (!win_valid(wp)) { // autocommands messed wp up
|
if (!win_valid(wp)) { // autocommands messed wp up
|
||||||
nextwp = firstwin;
|
nextwp = firstwin;
|
||||||
@ -4136,10 +4136,10 @@ int win_new_tabpage(int after, char_u *filename)
|
|||||||
*/
|
*/
|
||||||
int may_open_tabpage(void)
|
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) {
|
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;
|
postponed_split_tab = 0;
|
||||||
return win_new_tabpage(n, NULL);
|
return win_new_tabpage(n, NULL);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ describe('search_regcomp', function()
|
|||||||
--crafted to call reverse_text with invalid utf
|
--crafted to call reverse_text with invalid utf
|
||||||
globals.curwin.w_onebuf_opt.wo_rl = 1
|
globals.curwin.w_onebuf_opt.wo_rl = 1
|
||||||
globals.curwin.w_onebuf_opt.wo_rlc = to_cstr('s')
|
globals.curwin.w_onebuf_opt.wo_rlc = to_cstr('s')
|
||||||
globals.cmdmod.keeppatterns = 1
|
globals.cmdmod.cmod_flags = globals.CMOD_KEEPPATTERNS
|
||||||
local fail = search_regcomp("a\192", 0,0,0)
|
local fail = search_regcomp("a\192", 0,0,0)
|
||||||
eq(1, fail)
|
eq(1, fail)
|
||||||
eq("\192a", get_search_pat())
|
eq("\192a", get_search_pat())
|
||||||
|
Loading…
Reference in New Issue
Block a user