mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3747: cannot remove highlight from an existing sign
Problem: Cannot remove highlight from an existing sign. (James McCoy)
Solution: Only reject empty argument for a new sign.
0bac5fc5e1
This commit is contained in:
parent
d0b3efb7db
commit
4453d4c9f1
@ -943,19 +943,35 @@ int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (linehl != NULL) {
|
if (linehl != NULL) {
|
||||||
sp->sn_line_hl = syn_check_group((char *)linehl, (int)STRLEN(linehl));
|
if (*linehl == NUL) {
|
||||||
|
sp->sn_line_hl = 0;
|
||||||
|
} else {
|
||||||
|
sp->sn_line_hl = syn_check_group((char *)linehl, (int)STRLEN(linehl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texthl != NULL) {
|
if (texthl != NULL) {
|
||||||
sp->sn_text_hl = syn_check_group((char *)texthl, (int)STRLEN(texthl));
|
if (*texthl == NUL) {
|
||||||
|
sp->sn_text_hl = 0;
|
||||||
|
} else {
|
||||||
|
sp->sn_text_hl = syn_check_group((char *)texthl, (int)STRLEN(texthl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (culhl != NULL) {
|
if (culhl != NULL) {
|
||||||
sp->sn_cul_hl = syn_check_group((char *)culhl, (int)STRLEN(culhl));
|
if (*culhl == NUL) {
|
||||||
|
sp->sn_cul_hl = 0;
|
||||||
|
} else {
|
||||||
|
sp->sn_cul_hl = syn_check_group((char *)culhl, (int)STRLEN(culhl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numhl != NULL) {
|
if (numhl != NULL) {
|
||||||
sp->sn_num_hl = syn_check_group(numhl, (int)STRLEN(numhl));
|
if (*numhl == NUL) {
|
||||||
|
sp->sn_num_hl = 0;
|
||||||
|
} else {
|
||||||
|
sp->sn_num_hl = syn_check_group(numhl, (int)STRLEN(numhl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@ -1153,6 +1169,9 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
|
|||||||
char_u *culhl = NULL;
|
char_u *culhl = NULL;
|
||||||
char_u *numhl = NULL;
|
char_u *numhl = NULL;
|
||||||
int failed = false;
|
int failed = false;
|
||||||
|
sign_T *sp_prev;
|
||||||
|
|
||||||
|
bool exists = sign_find(sign_name, &sp_prev) != NULL;
|
||||||
|
|
||||||
// set values for a defined sign.
|
// set values for a defined sign.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -1169,28 +1188,28 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
|
|||||||
text = vim_strnsave(arg, (size_t)(p - arg));
|
text = vim_strnsave(arg, (size_t)(p - arg));
|
||||||
} else if (STRNCMP(arg, "linehl=", 7) == 0) {
|
} else if (STRNCMP(arg, "linehl=", 7) == 0) {
|
||||||
arg += 7;
|
arg += 7;
|
||||||
if (check_empty_group(p - arg, "linehl") == FAIL) {
|
if (!exists && check_empty_group(p - arg, "linehl") == FAIL) {
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
linehl = vim_strnsave(arg, (size_t)(p - arg));
|
linehl = vim_strnsave(arg, (size_t)(p - arg));
|
||||||
} else if (STRNCMP(arg, "texthl=", 7) == 0) {
|
} else if (STRNCMP(arg, "texthl=", 7) == 0) {
|
||||||
arg += 7;
|
arg += 7;
|
||||||
if (check_empty_group(p - arg, "texthl") == FAIL) {
|
if (!exists && check_empty_group(p - arg, "texthl") == FAIL) {
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
texthl = vim_strnsave(arg, (size_t)(p - arg));
|
texthl = vim_strnsave(arg, (size_t)(p - arg));
|
||||||
} else if (STRNCMP(arg, "culhl=", 6) == 0) {
|
} else if (STRNCMP(arg, "culhl=", 6) == 0) {
|
||||||
arg += 6;
|
arg += 6;
|
||||||
if (check_empty_group(p - arg, "culhl") == FAIL) {
|
if (!exists && check_empty_group(p - arg, "culhl") == FAIL) {
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
culhl = vim_strnsave(arg, (size_t)(p - arg));
|
culhl = vim_strnsave(arg, (size_t)(p - arg));
|
||||||
} else if (STRNCMP(arg, "numhl=", 6) == 0) {
|
} else if (STRNCMP(arg, "numhl=", 6) == 0) {
|
||||||
arg += 6;
|
arg += 6;
|
||||||
if (check_empty_group(p - arg, "numhl") == FAIL) {
|
if (!exists && check_empty_group(p - arg, "numhl") == FAIL) {
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -126,9 +126,34 @@ func Test_sign()
|
|||||||
" call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:')
|
" call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:')
|
||||||
call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:')
|
call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:')
|
||||||
|
|
||||||
call assert_fails("sign define Sign4 linehl=", 'E1249: Group name missing for linehl')
|
" an empty highlight argument for a new sign is an error
|
||||||
call assert_fails("sign define Sign4 culhl=", 'E1249: Group name missing for culhl')
|
call assert_fails("sign define SignX linehl=", 'E1249: Group name missing for linehl')
|
||||||
call assert_fails("sign define Sign4 texthl=", 'E1249: Group name missing for texthl')
|
call assert_fails("sign define SignX culhl=", 'E1249: Group name missing for culhl')
|
||||||
|
call assert_fails("sign define SignX texthl=", 'E1249: Group name missing for texthl')
|
||||||
|
|
||||||
|
" an empty highlight argument for an existing sign clears it
|
||||||
|
sign define SignY texthl=TextHl culhl=CulHl linehl=LineHl
|
||||||
|
let sl = sign_getdefined('SignY')[0]
|
||||||
|
call assert_equal('TextHl', sl.texthl)
|
||||||
|
call assert_equal('CulHl', sl.culhl)
|
||||||
|
call assert_equal('LineHl', sl.linehl)
|
||||||
|
|
||||||
|
sign define SignY texthl= culhl=CulHl linehl=LineHl
|
||||||
|
let sl = sign_getdefined('SignY')[0]
|
||||||
|
call assert_false(has_key(sl, 'texthl'))
|
||||||
|
call assert_equal('CulHl', sl.culhl)
|
||||||
|
call assert_equal('LineHl', sl.linehl)
|
||||||
|
|
||||||
|
sign define SignY linehl=
|
||||||
|
let sl = sign_getdefined('SignY')[0]
|
||||||
|
call assert_false(has_key(sl, 'linehl'))
|
||||||
|
call assert_equal('CulHl', sl.culhl)
|
||||||
|
|
||||||
|
sign define SignY culhl=
|
||||||
|
let sl = sign_getdefined('SignY')[0]
|
||||||
|
call assert_false(has_key(sl, 'culhl'))
|
||||||
|
|
||||||
|
sign undefine SignY
|
||||||
|
|
||||||
" define sign with whitespace
|
" define sign with whitespace
|
||||||
sign define Sign4 text=\ X linehl=Comment
|
sign define Sign4 text=\ X linehl=Comment
|
||||||
|
Loading…
Reference in New Issue
Block a user