4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Syntax highlighting hangs on an empty match of an item with a
12 nextgroup. (Charles Campbell)
13 Solution: Remember that the item has already matched and don't match it
14 again at the same position.
18 *** ../vim-6.2.218/src/syntax.c Sat Sep 27 19:26:33 2003
19 --- src/syntax.c Thu Jan 29 21:14:40 2004
22 static void validate_current_state __ARGS((void));
23 static int syn_finish_line __ARGS((int syncing));
24 static int syn_current_attr __ARGS((int syncing, int displaying));
25 ! static int did_match_already __ARGS((int idx));
26 static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si));
27 static void check_state_ends __ARGS((void));
28 static void update_si_attr __ARGS((int idx));
30 static void validate_current_state __ARGS((void));
31 static int syn_finish_line __ARGS((int syncing));
32 static int syn_current_attr __ARGS((int syncing, int displaying));
33 ! static int did_match_already __ARGS((int idx, garray_T *gap));
34 static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si));
35 static void check_state_ends __ARGS((void));
36 static void update_si_attr __ARGS((int idx));
40 reg_extmatch_T *cur_extmatch = NULL;
41 char_u *line; /* current line. NOTE: becomes invalid after
42 looking for a pattern match! */
44 + /* variables for zero-width matches that have a "nextgroup" argument */
46 int zero_width_next_list = FALSE;
47 + garray_T zero_width_next_ga;
50 * No character, no attributes! Past end of line?
54 && (syn_buf->b_keywtab != NULL
55 || syn_buf->b_keywtab_ic != NULL);
57 + /* Init the list of zero-width matches with a nextlist. This is used to
58 + * avoid matching the same item in the same position twice. */
59 + ga_init2(&zero_width_next_ga, sizeof(int), 10);
62 * Repeat matching keywords and patterns, to find contained items at the
63 * same column. This stops when there are no extra matches at the current
66 * before, skip it. Must retry in the next
67 * column, because it may match from there.
69 ! if (did_match_already(idx))
71 try_next_column = TRUE;
74 * before, skip it. Must retry in the next
75 * column, because it may match from there.
77 ! if (did_match_already(idx, &zero_width_next_ga))
79 try_next_column = TRUE;
84 current_next_flags = lspp->sp_flags;
85 keep_next_list = TRUE;
86 zero_width_next_list = TRUE;
88 + /* Add the index to a list, so that we can check
89 + * later that we don't match it again (and cause an
91 + if (ga_grow(&zero_width_next_ga, 1) == OK)
93 + ((int *)(zero_width_next_ga.ga_data))
94 + [zero_width_next_ga.ga_len++] = next_match_idx;
95 + --zero_width_next_ga.ga_room;
103 && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)))
104 current_next_list = NULL;
106 + if (zero_width_next_ga.ga_len > 0)
107 + ga_clear(&zero_width_next_ga);
109 /* No longer need external matches. But keep next_match_extmatch. */
110 unref_extmatch(re_extmatch_out);
111 re_extmatch_out = NULL;
114 * Check if we already matched pattern "idx" at the current column.
117 ! did_match_already(idx)
122 for (i = current_state.ga_len; --i >= 0; )
124 if (CUR_STATE(i).si_m_startcol == (int)current_col
125 && CUR_STATE(i).si_m_lnum == (int)current_lnum
126 && CUR_STATE(i).si_idx == idx)
133 * Check if we already matched pattern "idx" at the current column.
136 ! did_match_already(idx, gap)
142 for (i = current_state.ga_len; --i >= 0; )
143 if (CUR_STATE(i).si_m_startcol == (int)current_col
144 && CUR_STATE(i).si_m_lnum == (int)current_lnum
145 && CUR_STATE(i).si_idx == idx)
148 ! /* Zero-width matches with a nextgroup argument are not put on the syntax
149 ! * stack, and can only be matched once anyway. */
150 ! for (i = gap->ga_len; --i >= 0; )
151 ! if (((int *)(gap->ga_data))[i] == idx)
157 *** ../vim-6.2.218/src/version.c Sun Feb 1 19:59:21 2004
158 --- src/version.c Sun Feb 1 20:00:45 2004
162 { /* Add new patch number below this line */
168 The Feynman problem solving Algorithm:
169 1) Write down the problem
171 3) Write down the answer
173 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
174 /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
175 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
176 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///