0
0
mirror of https://github.com/vim/vim.git synced 2025-10-17 07:44:28 -04:00

patch 9.1.1810: completion: "longest" doesn't work for manual completion with 'ac'

Problem:  completion: "longest" doesn't work for manual completion when
          'autocomplete' is on (after 9.1.1800).
Solution: Only reset compl_get_longest when enabling autocompletion
          (zeertzjq).

closes: #18430

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2025-09-29 20:11:37 +00:00
committed by Christian Brabandt
parent c6802f41da
commit b3966d6a8e
3 changed files with 24 additions and 4 deletions

View File

@@ -2511,7 +2511,10 @@ ins_compl_new_leader(void)
save_w_wrow = curwin->w_wrow;
save_w_leftcol = curwin->w_leftcol;
compl_restarting = TRUE;
compl_autocomplete = ins_compl_has_autocomplete();
if (ins_compl_has_autocomplete())
ins_compl_enable_autocomplete();
else
compl_autocomplete = FALSE;
if (ins_complete(Ctrl_N, FALSE) == FAIL)
compl_cont_status = 0;
compl_restarting = FALSE;
@@ -3100,8 +3103,7 @@ ins_compl_prep(int c)
if (ctrl_x_mode_not_defined_yet()
|| (ctrl_x_mode_normal() && !compl_started))
{
compl_get_longest = (get_cot_flags() & COT_LONGEST)
&& !ins_compl_has_autocomplete();
compl_get_longest = (get_cot_flags() & COT_LONGEST);
compl_used_match = TRUE;
}
@@ -7388,6 +7390,7 @@ ins_compl_enable_autocomplete(void)
{
#ifdef ELAPSED_FUNC
compl_autocomplete = TRUE;
compl_get_longest = FALSE;
#endif
}

View File

@@ -5871,7 +5871,7 @@ func Test_autocomplete_longest()
call feedkeys("Go\<ESC>", 'tx')
call DoTest("f\<C-N>\<C-N>\<BS>\<BS>\<BS>\<BS>", 'foo', 3)
" Issue #18410: When both 'preinsert' and 'longest' are set, 'preinsert'
" Issue #18410: When both "preinsert" and "longest" are set, "preinsert"
" takes precedence
%delete
set autocomplete completeopt+=longest,preinsert
@@ -5922,6 +5922,21 @@ func Test_autocomplete_longest()
%delete _
delfunc CheckUndo
" Check that behavior of "longest" in manual completion is unchanged.
for ac in [v:false, v:true]
let &ac = ac
set completeopt=menuone,longest
call feedkeys("Ssign u\<C-X>\<C-V>", 'tx')
call assert_equal('sign un', getline('.'))
call feedkeys("Ssign u\<C-X>\<C-V>\<C-V>", 'tx')
call assert_equal('sign undefine', getline('.'))
call feedkeys("Ssign u\<C-X>\<C-V>\<C-V>\<C-V>", 'tx')
call assert_equal('sign unplace', getline('.'))
call feedkeys("Ssign u\<C-X>\<C-V>\<C-V>\<C-V>\<C-V>", 'tx')
call assert_equal('sign u', getline('.'))
%delete
endfor
bw!
set cot& autocomplete&
delfunc GetLine

View File

@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1810,
/**/
1809,
/**/