381
381
suppress_errthrow = FALSE;
385
* If requested, store and reset the global values controlling the
386
* exception handling (used when debugging). Otherwise clear it to avoid
387
* a bogus compiler warning when the optimizer uses inline functions...
389
if (flags & DOCMD_EXCRESET)
384
// If requested, store and reset the global values controlling the
385
// exception handling (used when debugging). Otherwise clear it to avoid
386
// a bogus compiler warning when the optimizer uses inline functions...
387
if (flags & DOCMD_EXCRESET) {
390
388
save_dbg_stuff(&debug_saved);
392
memset(&debug_saved, 0, 1);
390
memset(&debug_saved, 0, sizeof(debug_saved));
394
393
initial_trylevel = trylevel;
1702
1701
p = vim_strnsave(ea.cmd, p - ea.cmd);
1703
1702
int ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
1705
if (ret && !aborting()) {
1706
p = find_command(&ea, NULL);
1704
// If the autocommands did something and didn't cause an error, try
1705
// finding the command again.
1706
p = (ret && !aborting()) ? find_command(&ea, NULL) : NULL;
1710
1709
if (p == NULL) {
2348
2347
eap->cmdidx = CMD_k;
2350
2349
} else if (p[0] == 's'
2351
&& ((p[1] == 'c' && p[2] != 's' && p[2] != 'r'
2352
&& p[3] != 'i' && p[4] != 'p')
2352
|| (p[2] != 's' && p[2] != 'r'
2354
|| (p[3] != 'i' && p[4] != 'p')))))
2354
2356
|| (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g')
2679
while (ASCII_ISALPHA(*p) || *p == '*') /* Allow * wild card */
2681
/* check for non-alpha command */
2682
if (p == cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL)
2684
/* for python 3.x: ":py3*" commands completion */
2681
while (ASCII_ISALPHA(*p) || *p == '*') { // Allow * wild card
2684
// a user command may contain digits
2685
if (ASCII_ISUPPER(cmd[0])) {
2686
while (ASCII_ISALNUM(*p) || *p == '*') {
2690
// for python 3.x: ":py3*" commands completion
2685
2691
if (cmd[0] == 'p' && cmd[1] == 'y' && p == cmd + 2 && *p == '3') {
2687
while (ASCII_ISALPHA(*p) || *p == '*')
2693
while (ASCII_ISALPHA(*p) || *p == '*') {
2697
// check for non-alpha command
2698
if (p == cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) {
2690
2701
len = (int)(p - cmd);
4308
4321
static void ex_mapclear(exarg_T *eap)
4310
map_clear(eap->cmd, eap->arg, eap->forceit, FALSE);
4323
map_clear_mode(eap->cmd, eap->arg, eap->forceit, false);
4316
4329
static void ex_abclear(exarg_T *eap)
4318
map_clear(eap->cmd, eap->arg, TRUE, TRUE);
4331
map_clear_mode(eap->cmd, eap->arg, true, true);
4321
4334
static void ex_autocmd(exarg_T *eap)
6277
6290
if (eap->cmdidx == CMD_tabedit
6278
6291
|| eap->cmdidx == CMD_tabfind
6279
6292
|| eap->cmdidx == CMD_tabnew) {
6280
if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab
6281
: eap->addr_count == 0 ? 0
6282
: (int)eap->line2 + 1) != FAIL) {
6283
apply_autocmds(EVENT_TABNEW, eap->arg, eap->arg, FALSE, curbuf);
6293
if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab : eap->addr_count == 0
6294
? 0 : (int)eap->line2 + 1, eap->arg) != FAIL) {
6284
6295
do_exedit(eap, old_curwin);
6285
6296
apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, FALSE, curbuf);
8769
* Return non-zero if window "wp" is to be stored in the Session.
8785
/// Return non-zero if window "wp" is to be stored in the Session.
8771
8786
static int ses_do_win(win_T *wp)
8773
8788
if (wp->w_buffer->b_fname == NULL
8774
/* When 'buftype' is "nofile" can't restore the window contents. */
8775
|| bt_nofile(wp->w_buffer)
8789
// When 'buftype' is "nofile" can't restore the window contents.
8790
|| (!wp->w_buffer->terminal && bt_nofile(wp->w_buffer))) {
8777
8791
return ssop_flags & SSOP_BLANK;
8778
if (wp->w_buffer->b_help)
8793
if (wp->w_buffer->b_help) {
8779
8794
return ssop_flags & SSOP_HELP;
9216
static int filetype_detect = FALSE;
9217
static int filetype_plugin = FALSE;
9218
static int filetype_indent = FALSE;
9232
static TriState filetype_detect = kNone;
9233
static TriState filetype_plugin = kNone;
9234
static TriState filetype_indent = kNone;
9221
9237
* ":filetype [plugin] [indent] {on,off,detect}"
9229
9245
static void ex_filetype(exarg_T *eap)
9231
9247
char_u *arg = eap->arg;
9248
bool plugin = false;
9249
bool indent = false;
9235
9251
if (*eap->arg == NUL) {
9236
9252
/* Print current status. */
9237
9253
smsg("filetype detection:%s plugin:%s indent:%s",
9238
filetype_detect ? "ON" : "OFF",
9239
filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF",
9240
filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF");
9254
filetype_detect == kTrue ? "ON" : "OFF",
9255
filetype_plugin == kTrue ? (filetype_detect == kTrue ? "ON" : "(on)") : "OFF", // NOLINT(whitespace/line_length)
9256
filetype_indent == kTrue ? (filetype_detect == kTrue ? "ON" : "(on)") : "OFF"); // NOLINT(whitespace/line_length)
9244
9260
/* Accept "plugin" and "indent" in any order. */
9246
9262
if (STRNCMP(arg, "plugin", 6) == 0) {
9248
9264
arg = skipwhite(arg + 6);
9251
9267
if (STRNCMP(arg, "indent", 6) == 0) {
9253
9269
arg = skipwhite(arg + 6);
9258
9274
if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) {
9259
9275
if (*arg == 'o' || !filetype_detect) {
9260
source_runtime((char_u *)FILETYPE_FILE, TRUE);
9261
filetype_detect = TRUE;
9276
source_runtime((char_u *)FILETYPE_FILE, true);
9277
filetype_detect = kTrue;
9263
source_runtime((char_u *)FTPLUGIN_FILE, TRUE);
9264
filetype_plugin = TRUE;
9279
source_runtime((char_u *)FTPLUGIN_FILE, true);
9280
filetype_plugin = kTrue;
9267
source_runtime((char_u *)INDENT_FILE, TRUE);
9268
filetype_indent = TRUE;
9283
source_runtime((char_u *)INDENT_FILE, true);
9284
filetype_indent = kTrue;
9271
9287
if (*arg == 'd') {
9275
9291
} else if (STRCMP(arg, "off") == 0) {
9276
9292
if (plugin || indent) {
9278
source_runtime((char_u *)FTPLUGOF_FILE, TRUE);
9279
filetype_plugin = FALSE;
9294
source_runtime((char_u *)FTPLUGOF_FILE, true);
9295
filetype_plugin = kFalse;
9282
source_runtime((char_u *)INDOFF_FILE, TRUE);
9283
filetype_indent = FALSE;
9298
source_runtime((char_u *)INDOFF_FILE, true);
9299
filetype_indent = kFalse;
9286
source_runtime((char_u *)FTOFF_FILE, TRUE);
9287
filetype_detect = FALSE;
9302
source_runtime((char_u *)FTOFF_FILE, true);
9303
filetype_detect = kFalse;
9290
9306
EMSG2(_(e_invarg2), arg);
9309
/// Do ":filetype plugin indent on" if user did not already do some
9310
/// permutation thereof.
9311
void filetype_maybe_enable(void)
9313
if (filetype_detect == kNone
9314
&& filetype_plugin == kNone
9315
&& filetype_indent == kNone) {
9316
source_runtime((char_u *)FILETYPE_FILE, true);
9317
filetype_detect = kTrue;
9318
source_runtime((char_u *)FTPLUGIN_FILE, true);
9319
filetype_plugin = kTrue;
9320
source_runtime((char_u *)INDENT_FILE, true);
9321
filetype_indent = kTrue;
9294
9326
* ":setfiletype {name}"
9327
9359
redraw_all_later(SOME_VALID);
9331
* ":[N]match {group} {pattern}"
9332
* Sets nextcmd to the start of the next command, if any. Also called when
9333
* skipping commands to find the next command.
9362
// ":[N]match {group} {pattern}"
9363
// Sets nextcmd to the start of the next command, if any. Also called when
9364
// skipping commands to find the next command.
9335
9365
static void ex_match(exarg_T *eap)
9343
if (eap->line2 <= 3)
9373
if (eap->line2 <= 3) {
9344
9374
id = eap->line2;
9346
9376
EMSG(e_invcmd);
9350
/* First clear any old pattern. */
9352
match_delete(curwin, id, FALSE);
9380
// First clear any old pattern.
9382
match_delete(curwin, id, false);
9354
if (ends_excmd(*eap->arg))
9385
if (ends_excmd(*eap->arg)) {
9355
9386
end = eap->arg;
9356
else if ((STRNICMP(eap->arg, "none", 4) == 0
9357
&& (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4]))))
9387
} else if ((STRNICMP(eap->arg, "none", 4) == 0
9388
&& (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) {
9358
9389
end = eap->arg + 4;
9360
9391
p = skiptowhite(eap->arg);
9362
9393
g = vim_strnsave(eap->arg, (int)(p - eap->arg));
9363
9395
p = skipwhite(p);
9364
9396
if (*p == NUL) {
9365
/* There must be two arguments. */
9397
// There must be two arguments.
9366
9399
EMSG2(_(e_invarg2), eap->arg);
9369
end = skip_regexp(p + 1, *p, TRUE, NULL);
9402
end = skip_regexp(p + 1, *p, true, NULL);
9370
9403
if (!eap->skip) {
9371
9404
if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) {
9372
9406
eap->errmsg = e_trailing;
9375
9409
if (*end != *p) {
9376
9411
EMSG2(_(e_invarg2), p);
9382
match_add(curwin, g, p + 1, 10, id, NULL);
9417
match_add(curwin, g, p + 1, 10, id, NULL, NULL);