diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2020-09-24 09:10:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 09:10:52 +0200 |
commit | b9ceac4650a7d7b731828a4fb82b92d01e88752b (patch) | |
tree | 3727841c4d139c51313c6d6d74b9c2fd28bbce1c /src/nvim/spell.c | |
parent | 4f8d98e583beb4c1abd5d57b9898548396633030 (diff) | |
parent | ca28cf5362c9f8cfcc60e28e20c2d455c5c37c77 (diff) | |
download | rneovim-b9ceac4650a7d7b731828a4fb82b92d01e88752b.tar.gz rneovim-b9ceac4650a7d7b731828a4fb82b92d01e88752b.tar.bz2 rneovim-b9ceac4650a7d7b731828a4fb82b92d01e88752b.zip |
Merge pull request #12955 from vigoux/vim-8.2.0953
[RFC] vim-patch:8.2.{0953,0955,0956,1678}
Diffstat (limited to 'src/nvim/spell.c')
-rw-r--r-- | src/nvim/spell.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c index dc1bfe25b4..f036d7fe04 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -362,6 +362,8 @@ size_t spell_check( size_t wrongcaplen = 0; int lpi; bool count_word = docount; + bool use_camel_case = *wp->w_s->b_p_spo != NUL; + bool camel_case = false; // A word never starts at a space or a control character. Return quickly // then, skipping over the character. @@ -394,9 +396,24 @@ size_t spell_check( mi.mi_word = ptr; mi.mi_fend = ptr; if (spell_iswordp(mi.mi_fend, wp)) { + int prev_upper; + int this_upper; + + if (use_camel_case) { + c = PTR2CHAR(mi.mi_fend); + this_upper = SPELL_ISUPPER(c); + } + do { MB_PTR_ADV(mi.mi_fend); - } while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp)); + if (use_camel_case) { + prev_upper = this_upper; + c = PTR2CHAR(mi.mi_fend); + this_upper = SPELL_ISUPPER(c); + camel_case = !prev_upper && this_upper; + } + } while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp) + && !camel_case); if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) { // Check word starting with capital letter. @@ -428,6 +445,11 @@ size_t spell_check( (void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1); mi.mi_fwordlen = (int)STRLEN(mi.mi_fword); + if (camel_case) { + // introduce a fake word end space into the folded word. + mi.mi_fword[mi.mi_fwordlen - 1] = ' '; + } + // The word is bad unless we recognize it. mi.mi_result = SP_BAD; mi.mi_result2 = SP_BAD; |