patch 9.1.1150: :hi completion may complete to wrong value
Problem: :highlight auto-complettion has a minor bug where an existing
highlight group with a cterm color being unset would result in
it being auto-completed to -1 in cmdline which is invalid.
Solution: Correctly check for whether an int value is set to non-zero
before retrieving the existing value for auto-complete. Also
do this for attr/string values as they previously worked only
by accident (Yee Cheng Chin).
closes: #16726
Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/highlight.c b/src/highlight.c
index 2d96566..755d75f 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -4531,14 +4531,17 @@
char_u buf[MAX_ATTR_LEN];
- if (expand_hi_synid != 0 && type != 0 && expand_hi_include_orig)
+ expand_hi_curvalue = NULL;
+ if (expand_hi_include_orig)
{
- // Retrieve the current value to go first in completion
- expand_hi_curvalue = highlight_arg_to_string(
- type, iarg, sarg, buf);
+ if (((type == LIST_ATTR || type == LIST_INT) && iarg != 0) ||
+ (type == LIST_STRING && sarg != NULL))
+ {
+ // Retrieve the current value to go first in completion
+ expand_hi_curvalue = highlight_arg_to_string(
+ type, iarg, sarg, buf);
+ }
}
- else
- expand_hi_curvalue = NULL;
if (expandfunc != NULL)
{