]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1201: 'completefuzzycollect' does not handle dictionary correctly v9.1.1201
authorglepnir <glephunter@gmail.com>
Thu, 13 Mar 2025 20:39:51 +0000 (21:39 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 13 Mar 2025 20:39:51 +0000 (21:39 +0100)
Problem:  'completefuzzycollect' does not handle dictionary correctly
Solution: check for ctrl_x_mode_dictionary (glepnir)

closes: #16867

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

index 75fa1cb9e573ac911d4bd8efc3d427682f9ba0c8..525a3a58ba79c57e3b5f128c98fdb07b8affb847 100644 (file)
@@ -2113,17 +2113,18 @@ A jump table for the options with a short description can be found at |Q_op|.
        find completion candidates instead of the standard prefix-based
        matching.  This option can contain the following values:
 
-       keyword         keywords in the current file |i_CTRL-X_CTRL-N|
-                       keywords with the ".", "w", "b", "u", "U" and
-                       "k{dict}" flags in 'complete'. |i_CTRL-N| |i_CTRL-P|
+       keyword         keywords in the current file    |i_CTRL-X_CTRL-N|
+                       keywords with flags ".", "w",   |i_CTRL-N| |i_CTRL-P|
+                       "b", "u", "U" and "k{dict}" in 'complete'
+                       keywords in 'dictionary'        |i_CTRL-X_CTRL-K|
 
-       files           file names  |i_CTRL-X_CTRL-F|
+       files           file names                      |i_CTRL-X_CTRL-F|
 
-       whole_line      whole lines |i_CTRL-X_CTRL-L|
+       whole_line      whole lines                     |i_CTRL-X_CTRL-L|
 
-       When used with 'completeopt' "longest" option, fuzzy collection can
-       identify the longest common string among the best fuzzy matches and
-       automatically insert it.
+       When used the 'completeopt' "longest" option value, fuzzy collection
+       can identify the longest common string among the best fuzzy matches
+       and insert it automatically.
 
                                                *'completeitemalign'* *'cia'*
 'completeitemalign' 'cia' string (default: "abbr,kind,menu")
index 35d20d01d6e8b38b4f9870881b7d072a9a11dfd2..49c7ee27f2a60b85b874f19e093b6bf62d07fb29 100644 (file)
@@ -764,17 +764,14 @@ ins_compl_add_infercase(
     static int
 cfc_has_mode(void)
 {
-    switch (ctrl_x_mode)
-    {
-       case CTRL_X_NORMAL:
-           return (cfc_flags & CFC_KEYWORD) != 0;
-       case CTRL_X_FILES:
-           return (cfc_flags & CFC_FILES) != 0;
-       case CTRL_X_WHOLE_LINE:
-           return (cfc_flags & CFC_WHOLELINE) != 0;
-       default:
-           return FALSE;
-    }
+    if (ctrl_x_mode_normal() || ctrl_x_mode_dictionary())
+       return (cfc_flags & CFC_KEYWORD) != 0;
+    else if (ctrl_x_mode_files())
+       return (cfc_flags & CFC_FILES) != 0;
+    else if (ctrl_x_mode_whole_line())
+       return (cfc_flags & CFC_WHOLELINE) != 0;
+    else
+       return FALSE;
 }
 
 /*
@@ -1792,7 +1789,7 @@ ins_compl_files(
     int                add_r;
     char_u     *leader = NULL;
     int                leader_len = 0;
-    int                in_fuzzy_collect = cfc_has_mode() && ctrl_x_mode_normal();
+    int                in_fuzzy_collect = cfc_has_mode();
     int                score = 0;
     int                len = 0;
     char_u     *line_end = NULL;
index e2a69f3832b7b8dce57bfb1153edf94efe37b978..5d0e54038c15f0bf7e4d602ac1c9f5230d885cfb 100644 (file)
@@ -2955,8 +2955,17 @@ func Test_complete_fuzzy_collect()
   call feedkeys("Gofuzzy\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<CR>\<Esc>0", 'tx!')
   call assert_equal('completefuzzycollect', getline(line('.') - 1))
 
+  " keywords in 'dictonary'
+  call writefile(['hello', 'think'], 'test_dict.txt', 'D')
+  set dict=test_dict.txt
+  call feedkeys("Sh\<C-X>\<C-K>\<C-N>\<CR>\<Esc>0", 'tx!')
+  call assert_equal('hello', getline(line('.') - 1))
+  call feedkeys("Sh\<C-X>\<C-K>\<C-N>\<C-N>\<CR>\<Esc>0", 'tx!')
+  call assert_equal('think', getline(line('.') - 1))
+
   bw!
   bw!
+  set dict&
   set completeopt& cfc& cpt&
 endfunc
 
index f65999a612414cf83572fd893642e41834e03164..b9fcedc01d67c4c14b581aef1919df090281fd8e 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1201,
 /**/
     1200,
 /**/