]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1059: completion: input text deleted with preinsert when adding leader v9.1.1059
authorglepnir <glephunter@gmail.com>
Fri, 31 Jan 2025 14:28:29 +0000 (15:28 +0100)
committerChristian Brabandt <cb@256bit.org>
Fri, 31 Jan 2025 14:28:29 +0000 (15:28 +0100)
Problem:  completion: input text deleted with preinsert when adding leader
Solution: remove compl_length and check the ptr for being equal
          to pattern when preinsert is active (glepnir)

closes: #16545

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

index 63b779dd18aed1bbfd3ba1f0a40c21350df86847..df757ce9b8aac9b26e8554253db6456ea94c02c2 100644 (file)
@@ -4094,7 +4094,7 @@ get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_pos)
        if (!in_fuzzy)
            ptr = ins_compl_get_next_word_or_line(st->ins_buf, st->cur_match_pos,
                                                               &len, &cont_s_ipos);
-       if (ptr == NULL)
+       if (ptr == NULL || (ins_compl_has_preinsert() && STRCMP(ptr, compl_pattern.string) == 0))
            continue;
 
        if (ins_compl_add_infercase(ptr, len, p_ic,
@@ -4342,7 +4342,7 @@ ins_compl_delete(void)
     int        has_preinsert = ins_compl_preinsert_effect();
     if (has_preinsert)
     {
-       col = compl_col + ins_compl_leader_len() - compl_length;
+       col += ins_compl_leader_len();
        curwin->w_cursor.col = compl_ins_end_col;
     }
 
index d0f90c881000df393511e0d3c5a27463450d08ba..49e44653a26ec9614d17fff4be889f028dc550ca 100644 (file)
@@ -3112,6 +3112,10 @@ function Test_completeopt_preinsert()
   call assert_equal("hello hero", getline('.'))
   call assert_equal(2, col('.'))
 
+  call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>er", 'tx')
+  call assert_equal("hero", getline('.'))
+  call assert_equal(3, col('.'))
+
   " can not work with fuzzy
   set cot+=fuzzy
   call feedkeys("S\<C-X>\<C-O>", 'tx')
index e69088d3c25cab589723b59fa7f3d36293f7debf..209baf1d8a514c234686b9dc23a3b6987e47caf1 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1059,
 /**/
     1058,
 /**/