patch 8.2.0945: cannot use "z=" when 'spell' is off
Problem: Cannot use "z=" when 'spell' is off.
Solution: Make "z=" work even when 'spell' is off. (Christian Brabandt,
Gary Johnson, closes #6227)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index e67aa58..1f53095 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -7596,9 +7596,30 @@
char_u *word = (char_u *)"";
hlf_T attr = HLF_COUNT;
int len = 0;
+#ifdef FEAT_SPELL
+ int wo_spell_save = curwin->w_p_spell;
+
+ 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));
+ curwin->w_p_spell = wo_spell_save;
+ return;
+ }
+#endif
if (rettv_list_alloc(rettv) == FAIL)
+ {
+#ifdef FEAT_SPELL
+ curwin->w_p_spell = wo_spell_save;
+#endif
return;
+ }
#ifdef FEAT_SPELL
if (argvars[0].v_type == VAR_UNKNOWN)
@@ -7611,7 +7632,7 @@
curwin->w_set_curswant = TRUE;
}
}
- else if (curwin->w_p_spell && *curbuf->b_s.b_p_spl != NUL)
+ else if (*curbuf->b_s.b_p_spl != NUL)
{
char_u *str = tv_get_string_chk(&argvars[0]);
int capcol = -1;
@@ -7633,6 +7654,7 @@
}
}
}
+ curwin->w_p_spell = wo_spell_save;
#endif
list_append_string(rettv->vval.v_list, word, len);
@@ -7658,13 +7680,32 @@
int i;
listitem_T *li;
int need_capital = FALSE;
+ int wo_spell_save = curwin->w_p_spell;
+
+ 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));
+ curwin->w_p_spell = wo_spell_save;
+ return;
+ }
#endif
if (rettv_list_alloc(rettv) == FAIL)
+ {
+#ifdef FEAT_SPELL
+ curwin->w_p_spell = wo_spell_save;
+#endif
return;
+ }
#ifdef FEAT_SPELL
- if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL)
+ if (*curwin->w_s->b_p_spl != NUL)
{
str = tv_get_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
@@ -7701,6 +7742,7 @@
}
ga_clear(&ga);
}
+ curwin->w_p_spell = wo_spell_save;
#endif
}