comparison src/spell.c @ 20808:411348fb49ba v8.2.0956

patch 8.2.0956: spell test fails Commit: https://github.com/vim/vim/commit/e0ebeda4d8219a8955001b43ef7a9268452ef7f5 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 10 22:17:58 2020 +0200 patch 8.2.0956: spell test fails Problem: Spell test fails. Solution: Add missing change the spell checking.
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Jun 2020 22:30:04 +0200
parents 90b96fa35e4b
children f9245f58c134
comparison
equal deleted inserted replaced
20807:18442f89dc2b 20808:411348fb49ba
171 int nrlen = 0; // found a number first 171 int nrlen = 0; // found a number first
172 int c; 172 int c;
173 int wrongcaplen = 0; 173 int wrongcaplen = 0;
174 int lpi; 174 int lpi;
175 int count_word = docount; 175 int count_word = docount;
176 int use_camel_case = *wp->w_s->b_p_spo != NUL;
177 int camel_case = 0;
176 178
177 // A word never starts at a space or a control character. Return quickly 179 // A word never starts at a space or a control character. Return quickly
178 // then, skipping over the character. 180 // then, skipping over the character.
179 if (*ptr <= ' ') 181 if (*ptr <= ' ')
180 return 1; 182 return 1;
202 // Find the normal end of the word (until the next non-word character). 204 // Find the normal end of the word (until the next non-word character).
203 mi.mi_word = ptr; 205 mi.mi_word = ptr;
204 mi.mi_fend = ptr; 206 mi.mi_fend = ptr;
205 if (spell_iswordp(mi.mi_fend, wp)) 207 if (spell_iswordp(mi.mi_fend, wp))
206 { 208 {
209 int prev_upper;
210 int this_upper;
211
212 if (use_camel_case)
213 {
214 c = PTR2CHAR(mi.mi_fend);
215 this_upper = SPELL_ISUPPER(c);
216 }
217
207 do 218 do
219 {
208 MB_PTR_ADV(mi.mi_fend); 220 MB_PTR_ADV(mi.mi_fend);
209 while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp)); 221 if (use_camel_case)
222 {
223 prev_upper = this_upper;
224 c = PTR2CHAR(mi.mi_fend);
225 this_upper = SPELL_ISUPPER(c);
226 camel_case = !prev_upper && this_upper;
227 }
228 } while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp)
229 && !camel_case);
210 230
211 if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) 231 if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL)
212 { 232 {
213 // Check word starting with capital letter. 233 // Check word starting with capital letter.
214 c = PTR2CHAR(ptr); 234 c = PTR2CHAR(ptr);
234 MB_PTR_ADV(mi.mi_fend); 254 MB_PTR_ADV(mi.mi_fend);
235 255
236 (void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, 256 (void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword,
237 MAXWLEN + 1); 257 MAXWLEN + 1);
238 mi.mi_fwordlen = (int)STRLEN(mi.mi_fword); 258 mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
259
260 if (camel_case)
261 // Introduce a fake word end space into the folded word.
262 mi.mi_fword[mi.mi_fwordlen - 1] = ' ';
239 263
240 // The word is bad unless we recognize it. 264 // The word is bad unless we recognize it.
241 mi.mi_result = SP_BAD; 265 mi.mi_result = SP_BAD;
242 mi.mi_result2 = SP_BAD; 266 mi.mi_result2 = SP_BAD;
243 267