vim-patch:8.0.0513: fix getting name of cleared highlight group (#8103)

Problem:    Getting name of cleared highlight group is wrong. (Matt Wozniski)
Solution:   Only skip over cleared names for completion. (closes vim/vim#1592)
            Also fix that a cleared group causes duplicate completions.
c96272e30e
This commit is contained in:
KunMing Xie
2018-03-09 02:49:21 +08:00
committed by Justin M. Keyes
parent 1d5eec2c62
commit 5ec0a6d13f
5 changed files with 28 additions and 9 deletions

View File

@@ -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) {