diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-06-27 06:45:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-27 06:45:00 +0800 |
| commit | a0a815ec57ec241bd9d7db139eb2591bf5ef24ac (patch) | |
| tree | 6ceb4a9e5b6656b0ca835ebf322d78f3d6ee32f8 /src/nvim/spell.c | |
| parent | 516d6318b78c6e7f4734ea155591aa457016aa81 (diff) | |
| parent | 6711d001c59a0b5f6cf3f5d53d837d41f1ec78a5 (diff) | |
| download | rneovim-a0a815ec57ec241bd9d7db139eb2591bf5ef24ac.tar.gz rneovim-a0a815ec57ec241bd9d7db139eb2591bf5ef24ac.tar.bz2 rneovim-a0a815ec57ec241bd9d7db139eb2591bf5ef24ac.zip | |
Merge pull request #18716 from zeertzjq/vim-8.2.5007
vim-patch:8.2.{3484,5007,5123}: spell suggestion fixes
Diffstat (limited to 'src/nvim/spell.c')
| -rw-r--r-- | src/nvim/spell.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 8f84204481..8ae846e074 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -3663,6 +3663,12 @@ static void suggest_try_change(suginfo_T *su) p = su->su_badptr + su->su_badlen; (void)spell_casefold(curwin, p, (int)STRLEN(p), fword + n, MAXWLEN - n); + // Make sure the resulting text is not longer than the original text. + n = (int)STRLEN(su->su_badptr); + if (n < MAXWLEN) { + fword[n] = NUL; + } + for (int lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi) { lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi); @@ -4375,7 +4381,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so #endif ++depth; sp = &stack[depth]; - ++sp->ts_fidx; + if (fword[sp->ts_fidx] != NUL) { + sp->ts_fidx++; + } tword[sp->ts_twordlen++] = c; sp->ts_arridx = idxs[arridx]; if (newscore == SCORE_SUBST) { @@ -4391,7 +4399,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so sp->ts_fcharstart = sp->ts_fidx - 1; sp->ts_isdiff = (newscore != 0) ? DIFF_YES : DIFF_NONE; - } else if (sp->ts_isdiff == DIFF_INSERT) { + } else if (sp->ts_isdiff == DIFF_INSERT && sp->ts_fidx > 0) { // When inserting trail bytes don't advance in the // bad word. sp->ts_fidx--; |