mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 08:28:34 +00:00
vim-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: vim/vim#18430
b3966d6a8e
This commit is contained in:
@@ -2266,7 +2266,11 @@ static void ins_compl_new_leader(void)
|
||||
// Matches were cleared, need to search for them now.
|
||||
// Set "compl_restarting" to avoid that the first match is inserted.
|
||||
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, true) == FAIL) {
|
||||
compl_cont_status = 0;
|
||||
}
|
||||
@@ -2736,8 +2740,7 @@ bool ins_compl_prep(int c)
|
||||
// Set "compl_get_longest" when finding the first matches.
|
||||
if (ctrl_x_mode_not_defined_yet()
|
||||
|| (ctrl_x_mode_normal() && !compl_started)) {
|
||||
compl_get_longest = (get_cot_flags() & kOptCotFlagLongest) != 0
|
||||
&& !ins_compl_has_autocomplete();
|
||||
compl_get_longest = (get_cot_flags() & kOptCotFlagLongest) != 0;
|
||||
compl_used_match = true;
|
||||
}
|
||||
|
||||
@@ -6293,6 +6296,7 @@ int ins_complete(int c, bool enable_pum)
|
||||
void ins_compl_enable_autocomplete(void)
|
||||
{
|
||||
compl_autocomplete = true;
|
||||
compl_get_longest = false;
|
||||
}
|
||||
|
||||
/// Remove (if needed) and show the popup menu
|
||||
|
@@ -5984,7 +5984,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
|
||||
@@ -6035,6 +6035,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
|
||||
|
Reference in New Issue
Block a user