comparison src/syntax.c @ 10624:5ac9d7920f11 v8.0.0201

patch 8.0.0201: completion of highlight groups includes cleared names commit https://github.com/vim/vim/commit/d61e8aaae57bd66279def479462bf11c22ec2f1c Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 17 17:44:46 2017 +0100 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.
author Christian Brabandt <cb@256bit.org>
date Tue, 17 Jan 2017 17:45:04 +0100
parents 4ee16e5e2e26
children 16fc46021e51
comparison
equal deleted inserted replaced
10623:832c1a17f5b6 10624:5ac9d7920f11
20 */ 20 */
21 struct hl_group 21 struct hl_group
22 { 22 {
23 char_u *sg_name; /* highlight group name */ 23 char_u *sg_name; /* highlight group name */
24 char_u *sg_name_u; /* uppercase of sg_name */ 24 char_u *sg_name_u; /* uppercase of sg_name */
25 int sg_cleared; /* "hi clear" was used */
25 /* for normal terminals */ 26 /* for normal terminals */
26 int sg_term; /* "term=" highlighting attributes */ 27 int sg_term; /* "term=" highlighting attributes */
27 char_u *sg_start; /* terminal string for start highl */ 28 char_u *sg_start; /* terminal string for start highl */
28 char_u *sg_stop; /* terminal string for stop highl */ 29 char_u *sg_stop; /* terminal string for stop highl */
29 int sg_term_attr; /* Screen attr for term mode */ 30 int sg_term_attr; /* Screen attr for term mode */
7325 HL_TABLE()[from_id - 1].sg_set |= SG_LINK; 7326 HL_TABLE()[from_id - 1].sg_set |= SG_LINK;
7326 HL_TABLE()[from_id - 1].sg_link = to_id; 7327 HL_TABLE()[from_id - 1].sg_link = to_id;
7327 #ifdef FEAT_EVAL 7328 #ifdef FEAT_EVAL
7328 HL_TABLE()[from_id - 1].sg_scriptID = current_SID; 7329 HL_TABLE()[from_id - 1].sg_scriptID = current_SID;
7329 #endif 7330 #endif
7331 HL_TABLE()[from_id - 1].sg_cleared = FALSE;
7330 redraw_all_later(SOME_VALID); 7332 redraw_all_later(SOME_VALID);
7331 } 7333 }
7332 } 7334 }
7333 7335
7334 /* Only call highlight_changed() once, after sourcing a syntax file */ 7336 /* Only call highlight_changed() once, after sourcing a syntax file */
8032 { 8034 {
8033 EMSG2(_("E423: Illegal argument: %s"), key_start); 8035 EMSG2(_("E423: Illegal argument: %s"), key_start);
8034 error = TRUE; 8036 error = TRUE;
8035 break; 8037 break;
8036 } 8038 }
8039 HL_TABLE()[idx].sg_cleared = FALSE;
8037 8040
8038 /* 8041 /*
8039 * When highlighting has been given for a group, don't link it. 8042 * When highlighting has been given for a group, don't link it.
8040 */ 8043 */
8041 if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) 8044 if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK))
8169 * Clear highlighting for one group. 8172 * Clear highlighting for one group.
8170 */ 8173 */
8171 static void 8174 static void
8172 highlight_clear(int idx) 8175 highlight_clear(int idx)
8173 { 8176 {
8177 HL_TABLE()[idx].sg_cleared = TRUE;
8178
8174 HL_TABLE()[idx].sg_term = 0; 8179 HL_TABLE()[idx].sg_term = 0;
8175 vim_free(HL_TABLE()[idx].sg_start); 8180 vim_free(HL_TABLE()[idx].sg_start);
8176 HL_TABLE()[idx].sg_start = NULL; 8181 HL_TABLE()[idx].sg_start = NULL;
8177 vim_free(HL_TABLE()[idx].sg_stop); 8182 vim_free(HL_TABLE()[idx].sg_stop);
8178 HL_TABLE()[idx].sg_stop = NULL; 8183 HL_TABLE()[idx].sg_stop = NULL;
9956 return (char_u *)"link"; 9961 return (char_u *)"link";
9957 if (idx == highlight_ga.ga_len + include_none + include_default + 1 9962 if (idx == highlight_ga.ga_len + include_none + include_default + 1
9958 && include_link != 0) 9963 && include_link != 0)
9959 return (char_u *)"clear"; 9964 return (char_u *)"clear";
9960 #endif 9965 #endif
9961 if (idx < 0 || idx >= highlight_ga.ga_len) 9966 if (idx < 0)
9967 return NULL;
9968 /* Items are never removed from the table, skip the ones that were cleared.
9969 */
9970 while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
9971 ++idx;
9972 if (idx >= highlight_ga.ga_len)
9962 return NULL; 9973 return NULL;
9963 return HL_TABLE()[idx].sg_name; 9974 return HL_TABLE()[idx].sg_name;
9964 } 9975 }
9965 #endif 9976 #endif
9966 9977