Mercurial > vim
diff src/syntax.c @ 11254:918942a3b0ef v8.0.0513
patch 8.0.0513: getting name of cleared highlight group is wrong
commit https://github.com/vim/vim/commit/c96272e30e2b81e5e0c8418f09d9db4e2fcd5d73
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 26 13:50:09 2017 +0200
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 https://github.com/vim/vim/issues/1592)
Also fix that a cleared group causes duplicate completions.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 26 Mar 2017 14:00:04 +0200 |
parents | e74af2aca96e |
children | 7cbcba782c4e |
line wrap: on
line diff
--- a/src/syntax.c +++ b/src/syntax.c @@ -9949,17 +9949,27 @@ highlight_list_two(int cnt, int attr) || 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)