aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/sign.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2021-12-05 21:57:22 -0500
committerJames McCoy <jamessan@jamessan.com>2021-12-08 21:47:58 -0500
commit4453d4c9f1e2cb93bf42e24a622ff00134d7229f (patch)
treedfc7ecfebc19d89f70241983053af8a6bd7ec642 /src/nvim/sign.c
parentd0b3efb7db90ea8fe2637c9538c8b63acc5fbd19 (diff)
downloadrneovim-4453d4c9f1e2cb93bf42e24a622ff00134d7229f.tar.gz
rneovim-4453d4c9f1e2cb93bf42e24a622ff00134d7229f.tar.bz2
rneovim-4453d4c9f1e2cb93bf42e24a622ff00134d7229f.zip
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. https://github.com/vim/vim/commit/0bac5fc5e125b7aa0f3b596c9b7f4381279e6688
Diffstat (limited to 'src/nvim/sign.c')
-rw-r--r--src/nvim/sign.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index ec0e50f6d4..8409c07439 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -943,19 +943,35 @@ int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text
}
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) {
- 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) {
- 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) {
- 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;
@@ -1153,6 +1169,9 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
char_u *culhl = NULL;
char_u *numhl = NULL;
int failed = false;
+ sign_T *sp_prev;
+
+ bool exists = sign_find(sign_name, &sp_prev) != NULL;
// set values for a defined sign.
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));
} else if (STRNCMP(arg, "linehl=", 7) == 0) {
arg += 7;
- if (check_empty_group(p - arg, "linehl") == FAIL) {
+ if (!exists && check_empty_group(p - arg, "linehl") == FAIL) {
failed = true;
break;
}
linehl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "texthl=", 7) == 0) {
arg += 7;
- if (check_empty_group(p - arg, "texthl") == FAIL) {
+ if (!exists && check_empty_group(p - arg, "texthl") == FAIL) {
failed = true;
break;
}
texthl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "culhl=", 6) == 0) {
arg += 6;
- if (check_empty_group(p - arg, "culhl") == FAIL) {
+ if (!exists && check_empty_group(p - arg, "culhl") == FAIL) {
failed = true;
break;
}
culhl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "numhl=", 6) == 0) {
arg += 6;
- if (check_empty_group(p - arg, "numhl") == FAIL) {
+ if (!exists && check_empty_group(p - arg, "numhl") == FAIL) {
failed = true;
break;
}