mirror of
https://github.com/neovim/neovim.git
synced 2025-09-09 04:48:18 +00:00
vim-patch:8.0.0198
Problem: Some syntax arguments take effect even after "if 0". (Taylor
Venable)
Solution: Properly skip the syntax statements. Make "syn case" and "syn
conceal" report the current state. Fix that "syn clear" didn't
reset the conceal flag. Add tests for :syntax skipping properly.
de318c5c35
This commit is contained in:
@@ -3019,12 +3019,19 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing)
|
||||
return;
|
||||
|
||||
next = skiptowhite(arg);
|
||||
if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2)
|
||||
if (*arg == NUL) {
|
||||
if (curwin->w_s->b_syn_conceal) {
|
||||
MSG(_("syn conceal on"));
|
||||
} else {
|
||||
MSG(_("syn conceal off"));
|
||||
}
|
||||
} else if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) {
|
||||
curwin->w_s->b_syn_conceal = TRUE;
|
||||
else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3)
|
||||
} else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) {
|
||||
curwin->w_s->b_syn_conceal = FALSE;
|
||||
else
|
||||
} else {
|
||||
EMSG2(_("E390: Illegal argument: %s"), arg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3040,12 +3047,19 @@ static void syn_cmd_case(exarg_T *eap, int syncing)
|
||||
return;
|
||||
|
||||
next = skiptowhite(arg);
|
||||
if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5)
|
||||
if (*arg == NUL) {
|
||||
if (curwin->w_s->b_syn_ic) {
|
||||
MSG(_("syntax case ignore"));
|
||||
} else {
|
||||
MSG(_("syntax case match"));
|
||||
}
|
||||
} else if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) {
|
||||
curwin->w_s->b_syn_ic = FALSE;
|
||||
else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6)
|
||||
} else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) {
|
||||
curwin->w_s->b_syn_ic = TRUE;
|
||||
else
|
||||
} else {
|
||||
EMSG2(_("E390: Illegal argument: %s"), arg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3061,7 +3075,15 @@ static void syn_cmd_spell(exarg_T *eap, int syncing)
|
||||
return;
|
||||
|
||||
next = skiptowhite(arg);
|
||||
if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) {
|
||||
if (*arg == NUL) {
|
||||
if (curwin->w_s->b_syn_spell == SYNSPL_TOP) {
|
||||
MSG(_("syntax spell toplevel"));
|
||||
} else if (curwin->w_s->b_syn_spell == SYNSPL_NOTOP) {
|
||||
MSG(_("syntax spell notoplevel"));
|
||||
} else {
|
||||
MSG(_("syntax spell default"));
|
||||
}
|
||||
} else if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) {
|
||||
curwin->w_s->b_syn_spell = SYNSPL_TOP;
|
||||
} else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10) {
|
||||
curwin->w_s->b_syn_spell = SYNSPL_NOTOP;
|
||||
@@ -3125,6 +3147,7 @@ void syntax_clear(synblock_T *block)
|
||||
block->b_syn_ic = FALSE; /* Use case, by default */
|
||||
block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */
|
||||
block->b_syn_containedin = FALSE;
|
||||
block->b_syn_conceal = FALSE;
|
||||
|
||||
/* free the keywords */
|
||||
clear_keywtab(&block->b_keywtab);
|
||||
@@ -4004,7 +4027,8 @@ static char_u *
|
||||
get_syn_options (
|
||||
char_u *arg, /* next argument to be checked */
|
||||
syn_opt_arg_T *opt, /* various things */
|
||||
int *conceal_char
|
||||
int *conceal_char,
|
||||
int skip /* TRUE if skipping over command */
|
||||
)
|
||||
{
|
||||
char_u *gname_start, *gname;
|
||||
@@ -4080,13 +4104,13 @@ get_syn_options (
|
||||
EMSG(_("E395: contains argument not accepted here"));
|
||||
return NULL;
|
||||
}
|
||||
if (get_id_list(&arg, 8, &opt->cont_list) == FAIL)
|
||||
if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL)
|
||||
return NULL;
|
||||
} else if (flagtab[fidx].argtype == 2) {
|
||||
if (get_id_list(&arg, 11, &opt->cont_in_list) == FAIL)
|
||||
if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL)
|
||||
return NULL;
|
||||
} else if (flagtab[fidx].argtype == 3) {
|
||||
if (get_id_list(&arg, 9, &opt->next_list) == FAIL)
|
||||
if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL)
|
||||
return NULL;
|
||||
} else if (flagtab[fidx].argtype == 11 && arg[5] == '=') {
|
||||
/* cchar=? */
|
||||
@@ -4257,7 +4281,11 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
|
||||
rest = get_group_name(arg, &group_name_end);
|
||||
|
||||
if (rest != NULL) {
|
||||
syn_id = syn_check_group(arg, (int)(group_name_end - arg));
|
||||
if (eap->skip) {
|
||||
syn_id = -1;
|
||||
} else {
|
||||
syn_id = syn_check_group(arg, (int)(group_name_end - arg));
|
||||
}
|
||||
if (syn_id != 0) {
|
||||
// Allocate a buffer, for removing backslashes in the keyword.
|
||||
keyword_copy = xmalloc(STRLEN(rest) + 1);
|
||||
@@ -4276,7 +4304,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
|
||||
cnt = 0;
|
||||
p = keyword_copy;
|
||||
for (; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest)) {
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char);
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
|
||||
if (rest == NULL || ends_excmd(*rest)) {
|
||||
break;
|
||||
}
|
||||
@@ -4375,7 +4403,7 @@ syn_cmd_match (
|
||||
syn_opt_arg.cont_list = NULL;
|
||||
syn_opt_arg.cont_in_list = NULL;
|
||||
syn_opt_arg.next_list = NULL;
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char);
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
|
||||
|
||||
/* get the pattern. */
|
||||
init_syn_patterns();
|
||||
@@ -4385,7 +4413,7 @@ syn_cmd_match (
|
||||
syn_opt_arg.flags |= HL_HAS_EOL;
|
||||
|
||||
/* Get options after the pattern */
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char);
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
|
||||
|
||||
if (rest != NULL) { /* all arguments are valid */
|
||||
/*
|
||||
@@ -4502,7 +4530,7 @@ syn_cmd_region (
|
||||
*/
|
||||
while (rest != NULL && !ends_excmd(*rest)) {
|
||||
/* Check for option arguments */
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char);
|
||||
rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip);
|
||||
if (rest == NULL || ends_excmd(*rest))
|
||||
break;
|
||||
|
||||
@@ -4926,12 +4954,14 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing)
|
||||
break;
|
||||
|
||||
clstr_list = NULL;
|
||||
if (get_id_list(&rest, opt_len, &clstr_list) == FAIL) {
|
||||
if (get_id_list(&rest, opt_len, &clstr_list, eap->skip) == FAIL) {
|
||||
EMSG2(_(e_invarg2), rest);
|
||||
break;
|
||||
}
|
||||
syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list,
|
||||
&clstr_list, list_op);
|
||||
if (scl_id >= 0) {
|
||||
syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list,
|
||||
&clstr_list, list_op);
|
||||
}
|
||||
got_clstr = TRUE;
|
||||
}
|
||||
|
||||
@@ -5181,8 +5211,9 @@ static int
|
||||
get_id_list (
|
||||
char_u **arg,
|
||||
int keylen, /* length of keyword */
|
||||
short **list /* where to store the resulting list, if not
|
||||
short **list, /* where to store the resulting list, if not
|
||||
NULL, the list is silently skipped! */
|
||||
int skip
|
||||
)
|
||||
{
|
||||
char_u *p = NULL;
|
||||
@@ -5251,7 +5282,9 @@ get_id_list (
|
||||
id = SYNID_CONTAINED;
|
||||
id += current_syn_inc_tag;
|
||||
} else if (name[1] == '@') {
|
||||
id = syn_check_cluster(name + 2, (int)(end - p - 1));
|
||||
if (!skip) {
|
||||
id = syn_check_cluster(name + 2, (int)(end - p - 1));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Handle full group name.
|
||||
|
Reference in New Issue
Block a user