diff options
author | Matthieu Coudron <mattator@gmail.com> | 2020-04-13 22:49:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 22:49:00 +0200 |
commit | 93b2cb7a3824f91ee24ddf57406d5682699f684b (patch) | |
tree | 4ea7bb4aca7520a26a749b0958046ba52b450d4f /src/nvim/spell.c | |
parent | 13b4a6fd4fa67794e76892cb362121a33a756f58 (diff) | |
parent | cf223e7d78df5e8a63b84d423be55a29eefd8883 (diff) | |
download | rneovim-93b2cb7a3824f91ee24ddf57406d5682699f684b.tar.gz rneovim-93b2cb7a3824f91ee24ddf57406d5682699f684b.tar.bz2 rneovim-93b2cb7a3824f91ee24ddf57406d5682699f684b.zip |
Merge pull request #11997 from janlazo/vim-8.1.2389
[RDY]vim-patch:8.1.{1745,2147,2280,2282,},8.2.{41,134,365,366,381,387,389,397,398,406,415,457,464,473,474,507,544,549}
Diffstat (limited to 'src/nvim/spell.c')
-rw-r--r-- | src/nvim/spell.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 6cb8d01f51..180073ade1 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2827,9 +2827,6 @@ void spell_suggest(int count) smsg(_("Sorry, only %" PRId64 " suggestions"), (int64_t)sug.su_ga.ga_len); } else { - XFREE_CLEAR(repl_from); - XFREE_CLEAR(repl_to); - // When 'rightleft' is set the list is drawn right-left. cmdmsg_rl = curwin->w_p_rl; if (cmdmsg_rl) @@ -2909,6 +2906,9 @@ void spell_suggest(int count) if (selected > 0 && selected <= sug.su_ga.ga_len && u_save_cursor() == OK) { // Save the from and to text for :spellrepall. + XFREE_CLEAR(repl_from); + XFREE_CLEAR(repl_to); + stp = &SUG(sug.su_ga, selected - 1); if (sug.su_badlen > stp->st_orglen) { // Replacing less than "su_badlen", append the remainder to @@ -5761,19 +5761,22 @@ cleanup_suggestions ( int maxscore, int keep // nr of suggestions to keep ) + FUNC_ATTR_NONNULL_ALL { suggest_T *stp = &SUG(*gap, 0); - // Sort the list. - qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), sug_compare); + if (gap->ga_len > 0) { + // Sort the list. + qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), sug_compare); - // Truncate the list to the number of suggestions that will be displayed. - if (gap->ga_len > keep) { - for (int i = keep; i < gap->ga_len; ++i) { - xfree(stp[i].st_word); + // Truncate the list to the number of suggestions that will be displayed. + if (gap->ga_len > keep) { + for (int i = keep; i < gap->ga_len; i++) { + xfree(stp[i].st_word); + } + gap->ga_len = keep; + return stp[keep - 1].st_score; } - gap->ga_len = keep; - return stp[keep - 1].st_score; } return maxscore; } |