diff options
author | dvejmz <dvejmz@gmail.com> | 2018-01-08 21:37:12 +0000 |
---|---|---|
committer | dvejmz <dvejmz@gmail.com> | 2018-01-09 22:11:16 +0000 |
commit | 7f70c5f7b7fd0c0241613f1cc189b5e26a7642dc (patch) | |
tree | 7bbcc4dabefbcdaae5b3ab65ac65040240f357cd /src/nvim/syntax.c | |
parent | 889bc3c20cf308b2bda43358639b739fe987e1ec (diff) | |
download | rneovim-7f70c5f7b7fd0c0241613f1cc189b5e26a7642dc.tar.gz rneovim-7f70c5f7b7fd0c0241613f1cc189b5e26a7642dc.tar.bz2 rneovim-7f70c5f7b7fd0c0241613f1cc189b5e26a7642dc.zip |
vim-patch:8.0.0201: completion of highlight groups includes cleared names
Problem: When completing a group name for a highlight or syntax command
cleared groups are included.
Solution: Skip groups that have been cleared.
https://github.com/vim/vim/commit/d61e8aaae57bd66279def479462bf11c22ec2f1c
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r-- | src/nvim/syntax.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2222f41c78..b274e22caa 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -52,6 +52,7 @@ static bool did_syntax_onoff = false; struct hl_group { char_u *sg_name; ///< highlight group name char_u *sg_name_u; ///< uppercase of sg_name + int sg_cleared; ///< "hi clear" was used int sg_attr; ///< Screen attr @see ATTR_ENTRY int sg_link; ///< link to this highlight group ID int sg_set; ///< combination of flags in \ref SG_SET @@ -6490,6 +6491,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) HL_TABLE()[from_id - 1].sg_set |= SG_LINK; HL_TABLE()[from_id - 1].sg_link = to_id; HL_TABLE()[from_id - 1].sg_scriptID = current_SID; + HL_TABLE()[from_id - 1].sg_cleared = false; redraw_all_later(SOME_VALID); } } @@ -6872,6 +6874,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) error = true; break; } + HL_TABLE()[idx].sg_cleared = false; // When highlighting has been given for a group, don't link it. if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) { @@ -6953,6 +6956,8 @@ static int hl_has_settings(int idx, int check_link) */ static void highlight_clear(int idx) { + HL_TABLE()[idx].sg_cleared = true; + HL_TABLE()[idx].sg_attr = 0; HL_TABLE()[idx].sg_cterm = 0; HL_TABLE()[idx].sg_cterm_bold = FALSE; @@ -7763,10 +7768,20 @@ 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 || idx >= highlight_ga.ga_len) { + } else if (idx < 0) { return NULL; } - return (const char *)HL_TABLE()[idx].sg_name; + + /* 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) { + return NULL; + } + return (const char *)HL_TABLE()[current_idx].sg_name; } color_name_table_T color_name_table[] = { |