diff options
author | ckelsel <ckelsel@hotmail.com> | 2018-02-15 22:50:41 +0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-03-04 16:34:59 +0100 |
commit | b615192a37eb025b71276635845b57831b9f2c6b (patch) | |
tree | 3372713365ac35cb9066b04efa1fb12264f420c6 /src/nvim/syntax.c | |
parent | 544cef0155ecb006c34e8471733cac6bdfd61989 (diff) | |
download | rneovim-b615192a37eb025b71276635845b57831b9f2c6b.tar.gz rneovim-b615192a37eb025b71276635845b57831b9f2c6b.tar.bz2 rneovim-b615192a37eb025b71276635845b57831b9f2c6b.zip |
vim-patch:8.0.0220: highlight completion misses some values #8013
Problem: Completion for :match does not show "none" and other missing
highlight names.
Solution: Skip over cleared entries before checking the index to be at the
end.
https://github.com/vim/vim/commit/15eedf1d621d980cb40f50cc6a78a09ab94388c7
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 70a2efb588..68f3329ce7 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7762,10 +7762,18 @@ 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. */ -const char *get_highlight_name(expand_T *const xp, const int idx) +const char *get_highlight_name(expand_T *const xp, int idx) FUNC_ATTR_WARN_UNUSED_RESULT { - // TODO(justinmk): 'xp' is unused + 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 (idx == highlight_ga.ga_len && include_none != 0) { return "none"; } else if (idx == highlight_ga.ga_len + include_none @@ -7777,20 +7785,10 @@ const char *get_highlight_name(expand_T *const xp, const int idx) } else if (idx == highlight_ga.ga_len + include_none + include_default + 1 && include_link != 0) { return "clear"; - } else if (idx < 0) { - return NULL; - } - - // Items are never removed from the table, skip the ones that were cleared. - int current_idx = idx; - while (current_idx < highlight_ga.ga_len - && HL_TABLE()[current_idx].sg_cleared) { - current_idx++; - } - if (current_idx >= highlight_ga.ga_len) { + } else if (idx >= highlight_ga.ga_len) { return NULL; } - return (const char *)HL_TABLE()[current_idx].sg_name; + return (const char *)HL_TABLE()[idx].sg_name; } color_name_table_T color_name_table[] = { |