aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/spell.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-12 15:07:11 -0400
committerGitHub <noreply@github.com>2021-06-12 15:07:11 -0400
commit12d8ff7ccdad4d5873347e8d318a47ac552941d7 (patch)
treef7167b901cd2fa667a4a835fe9153d5411b678ab /src/nvim/spell.c
parentd3bdde0bad12458128fae817aa348ac1d07b6f35 (diff)
parent6a4685fb0e62dbd7955f8698e3aa82f885026036 (diff)
downloadrneovim-12d8ff7ccdad4d5873347e8d318a47ac552941d7.tar.gz
rneovim-12d8ff7ccdad4d5873347e8d318a47ac552941d7.tar.bz2
rneovim-12d8ff7ccdad4d5873347e8d318a47ac552941d7.zip
Merge pull request #14785 from janlazo/vim-8.1.1838
vim-patch:8.1.{1838,1865},8.2.{38,39,46,945,948,2896}
Diffstat (limited to 'src/nvim/spell.c')
-rw-r--r--src/nvim/spell.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 10cc410e81..771c2106db 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -1343,7 +1343,7 @@ static bool no_spell_checking(win_T *wp)
{
if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL
|| GA_EMPTY(&wp->w_s->b_langp)) {
- EMSG(_("E756: Spell checking is not enabled"));
+ EMSG(_(e_no_spell));
return true;
}
return false;
@@ -2771,9 +2771,17 @@ void spell_suggest(int count)
int selected = count;
int badlen = 0;
int msg_scroll_save = msg_scroll;
+ const int wo_spell_save = curwin->w_p_spell;
- if (no_spell_checking(curwin))
+ if (!curwin->w_p_spell) {
+ did_set_spelllang(curwin);
+ curwin->w_p_spell = true;
+ }
+
+ if (*curwin->w_s->b_p_spl == NUL) {
+ EMSG(_(e_no_spell));
return;
+ }
if (VIsual_active) {
// Use the Visually selected text as the bad word. But reject
@@ -2966,6 +2974,7 @@ void spell_suggest(int count)
spell_find_cleanup(&sug);
xfree(line);
+ curwin->w_p_spell = wo_spell_save;
}
// Check if the word at line "lnum" column "col" is required to start with a
@@ -5761,7 +5770,9 @@ cleanup_suggestions (
xfree(stp[i].st_word);
}
gap->ga_len = keep;
- return stp[keep - 1].st_score;
+ if (keep >= 1) {
+ return stp[keep - 1].st_score;
+ }
}
}
return maxscore;