diff options
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 68f3329ce7..e2476f9b0b 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7758,20 +7758,26 @@ static void highlight_list_two(int cnt, int attr) } -/* - * Function given to ExpandGeneric() to obtain the list of group names. - * Also used for synIDattr() function. - */ +/// Function given to ExpandGeneric() to obtain the list of group names. const char *get_highlight_name(expand_T *const xp, int idx) FUNC_ATTR_WARN_UNUSED_RESULT { + return get_highlight_name_ext(xp, idx, true); +} + + +/// Obtain a highlight group name. +/// When "skip_cleared" is TRUE don't return a cleared entry. +const char *get_highlight_name_ext(expand_T *xp, int idx, int skip_cleared) + FUNC_ATTR_WARN_UNUSED_RESULT +{ 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++; + if (skip_cleared && idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared) { + return ""; } if (idx == highlight_ga.ga_len && include_none != 0) { |