patch 8.0.0513: getting name of cleared highlight group is wrong
Problem: Getting name of cleared highlight group is wrong. (Matt Wozniski)
Solution: Only skip over cleared names for completion. (closes #1592)
Also fix that a cleared group causes duplicate completions.
diff --git a/src/syntax.c b/src/syntax.c
index a8942e7..42a0bdc 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -9949,17 +9949,27 @@
|| defined(FEAT_SIGNS) || defined(PROTO)
/*
* Function given to ExpandGeneric() to obtain the list of group names.
- * Also used for synIDattr() function.
*/
char_u *
get_highlight_name(expand_T *xp UNUSED, int idx)
{
+ return get_highlight_name_ext(xp, idx, TRUE);
+}
+
+/*
+ * Obtain a highlight group name.
+ * When "skip_cleared" is TRUE don't return a cleared entry.
+ */
+ char_u *
+get_highlight_name_ext(expand_T *xp UNUSED, int idx, int skip_cleared)
+{
if (idx < 0)
return NULL;
- /* Items are never removed from the table, skip the ones that were cleared.
- */
- while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
- ++idx;
+
+ /* Items are never removed from the table, skip the ones that were
+ * cleared. */
+ if (skip_cleared && idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
+ return (char_u *)"";
#ifdef FEAT_CMDL_COMPL
if (idx == highlight_ga.ga_len && include_none != 0)