]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0036: completion: thesaurus completion incorrect with "longest/fuzzy" v9.2.0036
authorGirish Palya <girishji@gmail.com>
Sat, 21 Feb 2026 10:10:17 +0000 (10:10 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 21 Feb 2026 10:19:35 +0000 (10:19 +0000)
Problem:  completion: thesaurus completion incorrect with
          "longest/fuzzy" (Mao-Yining)
Solution: Disable fuzzy matching and longest-match insertion
          specifically for thesaurus completion (Girish Palya).

fixes:  #19356
closes: #19475

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
src/insexpand.c
src/testdir/test_edit.vim
src/version.c

index 22e2ce2e3448bd4bd34b6e447582bd51fc993d81..0798934c2db08452027ff40682e407b8a20711a8 100644 (file)
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.2.  Last change: 2026 Feb 17
+*options.txt*  For Vim version 9.2.  Last change: 2026 Feb 21
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -2257,11 +2257,13 @@ A jump table for the options with a short description can be found at |Q_op|.
           fuzzy    Enable |fuzzy-matching| for completion candidates.  This
                    allows for more flexible and intuitive matching, where
                    characters can be skipped and matches can be found even
-                   if the exact sequence is not typed.
+                   if the exact sequence is not typed (disabled for thesaurus
+                   completion |compl-thesaurus|).
 
           longest
                    When 'autocomplete' is not active, only the longest common
-                   prefix of the matches is inserted.  If the popup menu is
+                   prefix of the matches is inserted (disabled for thesaurus
+                   completion |compl-thesaurus|).  If the popup menu is
                    displayed, you can use CTRL-L to add more characters.
                    Whether case is ignored depends on the type of completion.
                    For buffer text the 'ignorecase' option applies.
index 38e92dacfd625973233f6da27007f60a98cc1b7d..bfae80f61bb60ae7fd9e2a2a5f27f538aa1db5ae 100644 (file)
@@ -829,7 +829,7 @@ ins_compl_add_infercase(
     static int
 cot_fuzzy(void)
 {
-    return (get_cot_flags() & COT_FUZZY) != 0;
+    return (get_cot_flags() & COT_FUZZY) != 0 && !ctrl_x_mode_thesaurus();
 }
 
 /*
@@ -1035,7 +1035,7 @@ ins_compl_add(
 
     // Find the longest common string if still doing that.
     if (compl_get_longest && (flags & CP_ORIGINAL_TEXT) == 0 && !cot_fuzzy()
-           && !ins_compl_preinsert_longest())
+           && !ins_compl_preinsert_longest() && !ctrl_x_mode_thesaurus())
        ins_compl_longest_match(match);
 
     return OK;
index 57680e40fd4ab050166c926975a3c227e042e997..6ac115d77545428d7c82a2e912eee437c76f2d9e 100644 (file)
@@ -919,7 +919,7 @@ func Test_edit_CTRL_S()
   bw!
 endfunc
 
-func Test_edit_CTRL_T()
+func Edit_CTRL_T()
   " Check for CTRL-T and CTRL-X CTRL-T in insert mode
   " 1) increase indent
   new
@@ -992,6 +992,29 @@ func Test_edit_CTRL_T()
   bw!
 endfunc
 
+func Test_edit_CTRL_T()
+  call Edit_CTRL_T()
+  set completeopt+=fuzzy
+  call Edit_CTRL_T()
+  set completeopt&
+endfunc
+
+func Test_edit_CTRL_T_longest()
+  " CTRL-X CTRL-T (thesaurus complete) with 'longest' should not insert
+  " longest match
+  set completeopt+=longest
+  new
+  call writefile(['angry furious mad madder maddest'], 'Xthesaurus', 'D')
+  set thesaurus=Xthesaurus
+  call setline(1, 'mad')
+  call cursor(1, 1)
+  call feedkeys("A\<c-x>\<c-t>\<cr>\<esc>", 'tnix')
+  call assert_equal(['mad', ''], getline(1, '$'))
+  bw!
+  set thesaurus=
+  set completeopt&
+endfunc
+
 " Test thesaurus completion with different encodings
 func Test_thesaurus_complete_with_encoding()
   call writefile(['angry furious mad enraged'], 'Xthesaurus', 'D')
index 9e140b13f021880925a50233126b7dd9cde63606..d38a46661314737f8d3933263c688bc13dbf4554 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    36,
 /**/
     35,
 /**/