Commit: patch 9.2.0081: Failed "z=" does not reset 'nospell' setting

3 views
Skip to first unread message

Christian Brabandt

unread,
Feb 28, 2026, 12:46:53 PM (4 days ago) Feb 28
to vim...@googlegroups.com
patch 9.2.0081: Failed "z=" does not reset 'nospell' setting

Commit: https://github.com/vim/vim/commit/eba078fc47b6e0a5b6bc032ab31f4296ed2ff2a6
Author: Luuk van Baal <luuk...@gmail.com>
Date: Sat Feb 28 17:40:32 2026 +0000

patch 9.2.0081: Failed "z=" does not reset 'nospell' setting

Problem: When z= fails due to no word being found, 'spelllang' being
unset or a multiline visual selection, 'nospell' is not
restored.
Solution: Jump to where the user configured value of 'spell' is restored
instead of returning early (Luuk van Baal).

closes: #19525

Signed-off-by: Luuk van Baal <luuk...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/spellsuggest.c b/src/spellsuggest.c
index 87efd0d5b..866eedf31 100644
--- a/src/spellsuggest.c
+++ b/src/spellsuggest.c
@@ -463,7 +463,7 @@ spell_check_sps(void)
void
spell_suggest(int count)
{
- char_u *line;
+ char_u *line = NULL;
pos_T prev_cursor = curwin->w_cursor;
char_u wcopy[MAXWLEN + 2];
char_u *p;
@@ -488,7 +488,7 @@ spell_suggest(int count)
if (*curwin->w_s->b_p_spl == NUL)
{
emsg(_(e_spell_checking_is_not_possible));
- return;
+ goto skip;
}

if (VIsual_active)
@@ -498,7 +498,7 @@ spell_suggest(int count)
if (curwin->w_cursor.lnum != VIsual.lnum)
{
vim_beep(BO_SPELL);
- return;
+ goto skip;
}
badlen = (int)curwin->w_cursor.col - (int)VIsual.col;
if (badlen < 0)
@@ -518,11 +518,11 @@ spell_suggest(int count)
// No bad word or it starts after the cursor: use the word under the
// cursor.
curwin->w_cursor = prev_cursor;
- line = ml_get_curline();
- p = line + curwin->w_cursor.col;
+ char_u *curline = ml_get_curline();
+ p = curline + curwin->w_cursor.col;
// Backup to before start of word.
- while (p > line && spell_iswordp_nmw(p, curwin))
- MB_PTR_BACK(line, p);
+ while (p > curline && spell_iswordp_nmw(p, curwin))
+ MB_PTR_BACK(curline, p);
// Forward to start of word.
while (*p != NUL && !spell_iswordp_nmw(p, curwin))
MB_PTR_ADV(p);
@@ -530,9 +530,9 @@ spell_suggest(int count)
if (!spell_iswordp_nmw(p, curwin)) // No word found.
{
beep_flush();
- return;
+ goto skip;
}
- curwin->w_cursor.col = (colnr_T)(p - line);
+ curwin->w_cursor.col = (colnr_T)(p - curline);
}

// Get the word and its length.
diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim
index 170ea5792..58a2d5870 100644
--- a/src/testdir/test_spell.vim
+++ b/src/testdir/test_spell.vim
@@ -1567,4 +1567,18 @@ let g:test_data_aff_sal = [
\"SAL Z S",
\ ]

+func Test_suggest_spell_restore()
+ norm! z=
+ call assert_equal(0, &spell)
+ set spelllang=
+ sil! norm! z=
+ call assert_equal(0, &spell)
+ set spelllang=en
+ call setline(1, ['1','2'])
+ norm! vjz=
+ call assert_equal(0, &spell)
+ set spelllang&
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_spell_utf8.vim b/src/testdir/test_spell_utf8.vim
index 2a5e8091f..fa9284be1 100644
--- a/src/testdir/test_spell_utf8.vim
+++ b/src/testdir/test_spell_utf8.vim
@@ -808,13 +808,14 @@ endfunc

func Test_check_empty_line()
" This was using freed memory
+ set spell
enew
spellgood! fl
norm z=
norm yy
sil! norm P]svc
norm P]s
-
+ set spell&
bwipe!
endfunc

diff --git a/src/version.c b/src/version.c
index 5e72c7842..d74162d43 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 81,
/**/
80,
/**/
Reply all
Reply to author
Forward
0 new messages