]>
Commit | Line | Data |
---|---|---|
193cbe32 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.3.043 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 6.3.043 | |
11 | Problem: 'hlsearch' highlighting sometimes disappears when inserting text | |
12 | in PHP code with syntax highlighting. (Marcel Svitalsky) | |
13 | Solution: Don't use pointers to remember where a match was found, use an | |
14 | index. The pointers may become invalid when searching in other | |
15 | lines. | |
16 | Files: src/screen.c | |
17 | ||
18 | ||
19 | *** ../vim-6.3.042/src/screen.c Sun Dec 5 14:57:15 2004 | |
20 | --- src/screen.c Tue Dec 7 13:09:09 2004 | |
21 | *************** | |
22 | *** 110,117 **** | |
23 | int attr; /* attributes to be used for a match */ | |
24 | int attr_cur; /* attributes currently active in win_line() */ | |
25 | linenr_T first_lnum; /* first lnum to search for multi-line pat */ | |
26 | ! char_u *startp; /* in win_line() points to char where HL starts */ | |
27 | ! char_u *endp; /* in win_line() points to char where HL ends */ | |
28 | } match_T; | |
29 | ||
30 | static match_T search_hl; /* used for 'hlsearch' highlight matching */ | |
31 | --- 110,117 ---- | |
32 | int attr; /* attributes to be used for a match */ | |
33 | int attr_cur; /* attributes currently active in win_line() */ | |
34 | linenr_T first_lnum; /* first lnum to search for multi-line pat */ | |
35 | ! colnr_T startcol; /* in win_line() points to char where HL starts */ | |
36 | ! colnr_T endcol; /* in win_line() points to char where HL ends */ | |
37 | } match_T; | |
38 | ||
39 | static match_T search_hl; /* used for 'hlsearch' highlight matching */ | |
40 | *************** | |
41 | *** 926,932 **** | |
42 | ||
43 | /* When a change starts above w_topline and the end is below | |
44 | * w_topline, start redrawing at w_topline. | |
45 | ! * If the end of the change is above w_topline: do like no changes was | |
46 | * made, but redraw the first line to find changes in syntax. */ | |
47 | if (mod_top != 0 && mod_top < wp->w_topline) | |
48 | { | |
49 | --- 926,932 ---- | |
50 | ||
51 | /* When a change starts above w_topline and the end is below | |
52 | * w_topline, start redrawing at w_topline. | |
53 | ! * If the end of the change is above w_topline: do like no change was | |
54 | * made, but redraw the first line to find changes in syntax. */ | |
55 | if (mod_top != 0 && mod_top < wp->w_topline) | |
56 | { | |
57 | *************** | |
58 | *** 2896,2903 **** | |
59 | shl = &search_hl; | |
60 | for (;;) | |
61 | { | |
62 | ! shl->startp = NULL; | |
63 | ! shl->endp = NULL; | |
64 | shl->attr_cur = 0; | |
65 | if (shl->rm.regprog != NULL) | |
66 | { | |
67 | --- 2896,2903 ---- | |
68 | shl = &search_hl; | |
69 | for (;;) | |
70 | { | |
71 | ! shl->startcol = MAXCOL; | |
72 | ! shl->endcol = MAXCOL; | |
73 | shl->attr_cur = 0; | |
74 | if (shl->rm.regprog != NULL) | |
75 | { | |
76 | *************** | |
77 | *** 2912,2936 **** | |
78 | if (shl->lnum != 0 && shl->lnum <= lnum) | |
79 | { | |
80 | if (shl->lnum == lnum) | |
81 | ! shl->startp = line + shl->rm.startpos[0].col; | |
82 | else | |
83 | ! shl->startp = line; | |
84 | if (lnum == shl->lnum + shl->rm.endpos[0].lnum | |
85 | - shl->rm.startpos[0].lnum) | |
86 | ! shl->endp = line + shl->rm.endpos[0].col; | |
87 | else | |
88 | ! shl->endp = line + MAXCOL; | |
89 | /* Highlight one character for an empty match. */ | |
90 | ! if (shl->startp == shl->endp) | |
91 | { | |
92 | #ifdef FEAT_MBYTE | |
93 | ! if (has_mbyte && *shl->endp != NUL) | |
94 | ! shl->endp += (*mb_ptr2len_check)(shl->endp); | |
95 | else | |
96 | #endif | |
97 | ! ++shl->endp; | |
98 | } | |
99 | ! if (shl->startp < ptr) /* match at leftcol */ | |
100 | { | |
101 | shl->attr_cur = shl->attr; | |
102 | search_attr = shl->attr; | |
103 | --- 2912,2936 ---- | |
104 | if (shl->lnum != 0 && shl->lnum <= lnum) | |
105 | { | |
106 | if (shl->lnum == lnum) | |
107 | ! shl->startcol = shl->rm.startpos[0].col; | |
108 | else | |
109 | ! shl->startcol = 0; | |
110 | if (lnum == shl->lnum + shl->rm.endpos[0].lnum | |
111 | - shl->rm.startpos[0].lnum) | |
112 | ! shl->endcol = shl->rm.endpos[0].col; | |
113 | else | |
114 | ! shl->endcol = MAXCOL; | |
115 | /* Highlight one character for an empty match. */ | |
116 | ! if (shl->startcol == shl->endcol) | |
117 | { | |
118 | #ifdef FEAT_MBYTE | |
119 | ! if (has_mbyte && line[shl->endcol] != NUL) | |
120 | ! shl->endcol += (*mb_ptr2len_check)(line + shl->endcol); | |
121 | else | |
122 | #endif | |
123 | ! ++shl->endcol; | |
124 | } | |
125 | ! if ((long)shl->startcol < v) /* match at leftcol */ | |
126 | { | |
127 | shl->attr_cur = shl->attr; | |
128 | search_attr = shl->attr; | |
129 | *************** | |
130 | *** 3193,3214 **** | |
131 | * Do this first for search_hl, then for match_hl, so that | |
132 | * ":match" overrules 'hlsearch'. | |
133 | */ | |
134 | shl = &search_hl; | |
135 | for (;;) | |
136 | { | |
137 | while (shl->rm.regprog != NULL) | |
138 | { | |
139 | ! if (shl->startp != NULL | |
140 | ! && ptr >= shl->startp | |
141 | ! && ptr < shl->endp) | |
142 | { | |
143 | shl->attr_cur = shl->attr; | |
144 | } | |
145 | ! else if (ptr == shl->endp) | |
146 | { | |
147 | shl->attr_cur = 0; | |
148 | ||
149 | - v = (long)(ptr - line); | |
150 | next_search_hl(wp, shl, lnum, (colnr_T)v); | |
151 | ||
152 | /* Need to get the line again, a multi-line regexp | |
153 | --- 3193,3214 ---- | |
154 | * Do this first for search_hl, then for match_hl, so that | |
155 | * ":match" overrules 'hlsearch'. | |
156 | */ | |
157 | + v = (long)(ptr - line); | |
158 | shl = &search_hl; | |
159 | for (;;) | |
160 | { | |
161 | while (shl->rm.regprog != NULL) | |
162 | { | |
163 | ! if (shl->startcol != MAXCOL | |
164 | ! && v >= (long)shl->startcol | |
165 | ! && v < (long)shl->endcol) | |
166 | { | |
167 | shl->attr_cur = shl->attr; | |
168 | } | |
169 | ! else if (v == (long)shl->endcol) | |
170 | { | |
171 | shl->attr_cur = 0; | |
172 | ||
173 | next_search_hl(wp, shl, lnum, (colnr_T)v); | |
174 | ||
175 | /* Need to get the line again, a multi-line regexp | |
176 | *************** | |
177 | *** 3218,3240 **** | |
178 | ||
179 | if (shl->lnum == lnum) | |
180 | { | |
181 | ! shl->startp = line + shl->rm.startpos[0].col; | |
182 | if (shl->rm.endpos[0].lnum == 0) | |
183 | ! shl->endp = line + shl->rm.endpos[0].col; | |
184 | else | |
185 | ! shl->endp = line + MAXCOL; | |
186 | ||
187 | ! if (shl->startp == shl->endp) | |
188 | { | |
189 | /* highlight empty match, try again after | |
190 | * it */ | |
191 | #ifdef FEAT_MBYTE | |
192 | if (has_mbyte) | |
193 | ! shl->endp += | |
194 | ! (*mb_ptr2len_check)(shl->endp); | |
195 | else | |
196 | #endif | |
197 | ! ++shl->endp; | |
198 | } | |
199 | ||
200 | /* Loop to check if the match starts at the | |
201 | --- 3218,3240 ---- | |
202 | ||
203 | if (shl->lnum == lnum) | |
204 | { | |
205 | ! shl->startcol = shl->rm.startpos[0].col; | |
206 | if (shl->rm.endpos[0].lnum == 0) | |
207 | ! shl->endcol = shl->rm.endpos[0].col; | |
208 | else | |
209 | ! shl->endcol = MAXCOL; | |
210 | ||
211 | ! if (shl->startcol == shl->endcol) | |
212 | { | |
213 | /* highlight empty match, try again after | |
214 | * it */ | |
215 | #ifdef FEAT_MBYTE | |
216 | if (has_mbyte) | |
217 | ! shl->endcol += (*mb_ptr2len_check)(line | |
218 | ! + shl->endcol); | |
219 | else | |
220 | #endif | |
221 | ! ++shl->endcol; | |
222 | } | |
223 | ||
224 | /* Loop to check if the match starts at the | |
225 | *************** | |
226 | *** 3868,3875 **** | |
227 | && ((area_attr != 0 && vcol == fromcol) | |
228 | #ifdef FEAT_SEARCH_EXTRA | |
229 | /* highlight 'hlsearch' match at end of line */ | |
230 | ! || ptr - 1 == search_hl.startp | |
231 | ! || ptr - 1 == match_hl.startp | |
232 | #endif | |
233 | )) | |
234 | { | |
235 | --- 3868,3875 ---- | |
236 | && ((area_attr != 0 && vcol == fromcol) | |
237 | #ifdef FEAT_SEARCH_EXTRA | |
238 | /* highlight 'hlsearch' match at end of line */ | |
239 | ! || (ptr - line) - 1 == (long)search_hl.startcol | |
240 | ! || (ptr - line) - 1 == (long)match_hl.startcol | |
241 | #endif | |
242 | )) | |
243 | { | |
244 | *************** | |
245 | *** 3906,3912 **** | |
246 | #ifdef FEAT_SEARCH_EXTRA | |
247 | if (area_attr == 0) | |
248 | { | |
249 | ! if (ptr - 1 == match_hl.startp) | |
250 | char_attr = match_hl.attr; | |
251 | else | |
252 | char_attr = search_hl.attr; | |
253 | --- 3906,3912 ---- | |
254 | #ifdef FEAT_SEARCH_EXTRA | |
255 | if (area_attr == 0) | |
256 | { | |
257 | ! if ((ptr - line) - 1 == (long)match_hl.startcol) | |
258 | char_attr = match_hl.attr; | |
259 | else | |
260 | char_attr = search_hl.attr; | |
261 | *** ../vim-6.3.042/src/version.c Mon Dec 6 11:51:12 2004 | |
262 | --- src/version.c Tue Dec 7 12:57:14 2004 | |
263 | *************** | |
264 | *** 643,644 **** | |
265 | --- 643,646 ---- | |
266 | { /* Add new patch number below this line */ | |
267 | + /**/ | |
268 | + 43, | |
269 | /**/ | |
270 | ||
271 | -- | |
272 | A)bort, R)etry, P)lease don't bother me again | |
273 | ||
274 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
275 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
276 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
277 | \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html /// |