]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1315: completion: issue with fuzzy completion and 'completefuzzycollect' v9.1.1315
authorglepnir <glephunter@gmail.com>
Thu, 17 Apr 2025 18:17:53 +0000 (20:17 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 17 Apr 2025 18:17:53 +0000 (20:17 +0200)
Problem:  chain complete does not work when 'cot' includes fuzzy
          and 'completefuzzycollect' collects wrong next word.
          (Konfekt)
Solution: compl_startpos is not set correctly, remove next word check
          in search_for_fuzzy_match (glepnir).

fixes #17131
fixes #16942
closes: #17136

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

index 8673e74551213c8c8976660addbda6f96f35254d..233586277eff47085fe6568aa29f78297cc3f7c7 100644 (file)
@@ -6101,7 +6101,6 @@ ins_compl_start(void)
     if (line_invalid)
        line = ml_get(curwin->w_cursor.lnum);
 
-    int in_fuzzy = get_cot_flags() & COT_FUZZY;
     if (compl_status_adding())
     {
        edit_submode_pre = (char_u *)_(" Adding");
@@ -6119,7 +6118,7 @@ ins_compl_start(void)
            compl_col = curwin->w_cursor.col;
            compl_lnum = curwin->w_cursor.lnum;
        }
-       else if (ctrl_x_mode_normal() && in_fuzzy)
+       else if (ctrl_x_mode_normal() && cfc_has_mode())
        {
            compl_startpos = curwin->w_cursor;
            compl_cont_status &= CONT_S_IPOS;
index abd74416d626c67a165b47d761fee991ed88f62a..68b2e727baf136bf7cfb5cf462629a00a9f49ba3 100644 (file)
@@ -5370,30 +5370,6 @@ search_for_fuzzy_match(
                                                    len, &current_pos, score);
                    if (found_new_match)
                    {
-                       if (ctrl_x_mode_normal())
-                       {
-                           if (STRNCMP(*ptr, pattern, *len) == 0 && pattern[*len] == NUL)
-                           {
-                               char_u  *next_word_end = find_word_start(*ptr + *len);
-                               if (*next_word_end != NUL && *next_word_end != NL)
-                               {
-                                   // Find end of the word.
-                                   if (has_mbyte)
-                                       while (*next_word_end != NUL)
-                                       {
-                                           int l = (*mb_ptr2len)(next_word_end);
-
-                                           if (l < 2 && !vim_iswordc(*next_word_end))
-                                               break;
-                                           next_word_end += l;
-                                       }
-                                   else
-                                      next_word_end = find_word_end(next_word_end);
-                               }
-
-                               *len = next_word_end - *ptr;
-                           }
-                       }
                        *pos = current_pos;
                        break;
                    }
index 2b14bfa760dc3833b007fbe66d90520e1499a304..916ad19fbc84f0475686639c7e14e69e770ec0d9 100644 (file)
@@ -3480,6 +3480,14 @@ func Test_complete_opt_fuzzy()
   call feedkeys("Sb\<C-X>\<C-P>\<C-N>\<C-Y>\<ESC>", 'tx')
   call assert_equal('b', getline('.'))
 
+  " chain completion
+  call feedkeys("Slore spum\<CR>lor\<C-X>\<C-P>\<C-X>\<C-P>\<ESC>", 'tx')
+  call assert_equal('lore spum', getline('.'))
+
+  " issue #15412
+  call feedkeys("Salpha bravio charlie\<CR>alpha\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<ESC>", 'tx')
+  call assert_equal('alpha bravio charlie', getline('.'))
+
   " clean up
   set omnifunc=
   bw!
@@ -3565,34 +3573,6 @@ func Test_complete_fuzzy_collect()
   call feedkeys("Su\<C-X>\<C-L>\<C-P>\<Esc>0", 'tx!')
   call assert_equal('no one can save me but you', getline('.'))
 
-  " issue #15412
-  call setline(1, ['alpha bravio charlie'])
-  call feedkeys("Salpha\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha bravio', getline('.'))
-  call feedkeys("Salp\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha', getline('.'))
-  call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha bravio', getline('.'))
-  call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha bravio charlie', getline('.'))
-
-  set complete-=i
-  call feedkeys("Salp\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha', getline('.'))
-  call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha bravio', getline('.'))
-  call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha bravio charlie', getline('.'))
-
-  call setline(1, ['alpha bravio charlie', 'alpha another'])
-  call feedkeys("Salpha\<C-X>\<C-N>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('alpha another', getline('.'))
-  call setline(1, ['你好 我好', '你好 他好'])
-  call feedkeys("S你好\<C-X>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('你好 我好', getline('.'))
-  call feedkeys("S你好\<C-X>\<C-N>\<C-N>\<Esc>0", 'tx!')
-  call assert_equal('你好 他好', getline('.'))
-
   " issue #15526
   set completeopt=menuone,menu,noselect
   call setline(1, ['Text', 'ToText', ''])
@@ -3618,6 +3598,11 @@ func Test_complete_fuzzy_collect()
   call feedkeys("Gofuzzy\<C-X>\<C-N>\<C-N>\<C-N>\<C-Y>\<Esc>0", 'tx!')
   call assert_equal('completefuzzycollect', getline('.'))
 
+  execute('%d _')
+  call setline(1, ['fuzzy', 'fuzzy foo', "fuzzy bar", 'fuzzycollect'])
+  call feedkeys("Gofuzzy\<C-X>\<C-N>\<C-N>\<C-N>\<C-Y>\<Esc>0", 'tx!')
+  call assert_equal('fuzzycollect', getline('.'))
+
   bw!
   bw!
   set dict&
index 5ced0fefdd0c13c9c532eda8735eb14c6d85aef0..9a1926004c5aaf551cb92e4f29372cc869407920 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1315,
 /**/
     1314,
 /**/