]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5123: using invalid index when looking for spell suggestions v8.2.5123
authorBram Moolenaar <Bram@vim.org>
Sat, 18 Jun 2022 13:09:08 +0000 (14:09 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 18 Jun 2022 13:09:08 +0000 (14:09 +0100)
Problem:    Using invalid index when looking for spell suggestions.
Solution:   Do not decrement the index when it is zero.

src/spellsuggest.c
src/testdir/test_spell.vim
src/version.c

index 5b460a3eaaef6f1c5d6ad57f0502b0ae6f54d7ea..8f9756534fa2e5740e29dca8bcd20fdca0c275f4 100644 (file)
@@ -1973,7 +1973,8 @@ suggest_trie_walk(
                            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;
index aa5744475338fae570c03379efba506c0995708f..0fd5ed91780fb0c9a4d9325948deb8063032127d 100644 (file)
@@ -70,6 +70,16 @@ func Test_z_equal_on_invalid_utf8_word()
   bwipe!
 endfunc
 
+func Test_z_equal_on_single_character()
+  " this was decrementing the index below zero
+  new
+  norm a0\Ê
+  norm zW
+  norm \16z=
+
+  bwipe!
+endfunc
+
 " Test spellbadword() with argument
 func Test_spellbadword()
   set spell
index 5411e1c189f3e6239b5bc3b762bbd6a9af3f0319..0a422742f1ad216f5a286b13728c201144252455 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5123,
 /**/
     5122,
 /**/