Skip to content

Commit bfb4eea

Browse files
glepnirchrisbra
authored andcommitted
patch 9.1.1059: completion: input text deleted with preinsert when adding leader
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent fe0a9a3 commit bfb4eea

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/insexpand.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4094,7 +4094,7 @@ get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_pos)
40944094
if (!in_fuzzy)
40954095
ptr = ins_compl_get_next_word_or_line(st->ins_buf, st->cur_match_pos,
40964096
&len, &cont_s_ipos);
4097-
if (ptr == NULL)
4097+
if (ptr == NULL || (ins_compl_has_preinsert() && STRCMP(ptr, compl_pattern.string) == 0))
40984098
continue;
40994099

41004100
if (ins_compl_add_infercase(ptr, len, p_ic,
@@ -4342,7 +4342,7 @@ ins_compl_delete(void)
43424342
int has_preinsert = ins_compl_preinsert_effect();
43434343
if (has_preinsert)
43444344
{
4345-
col = compl_col + ins_compl_leader_len() - compl_length;
4345+
col += ins_compl_leader_len();
43464346
curwin->w_cursor.col = compl_ins_end_col;
43474347
}
43484348

src/testdir/test_ins_complete.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,6 +3112,10 @@ function Test_completeopt_preinsert()
31123112
call assert_equal("hello hero", getline('.'))
31133113
call assert_equal(2, col('.'))
31143114

3115+
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>er", 'tx')
3116+
call assert_equal("hero", getline('.'))
3117+
call assert_equal(3, col('.'))
3118+
31153119
" can not work with fuzzy
31163120
set cot+=fuzzy
31173121
call feedkeys("S\<C-X>\<C-O>", 'tx')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1059,
707709
/**/
708710
1058,
709711
/**/

0 commit comments

Comments
 (0)