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.
|
// Matches were cleared, need to search for them now.
|
||||||
// Set "compl_restarting" to avoid that the first match is inserted.
|
// Set "compl_restarting" to avoid that the first match is inserted.
|
||||||
compl_restarting = true;
|
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) {
|
if (ins_complete(Ctrl_N, true) == FAIL) {
|
||||||
compl_cont_status = 0;
|
compl_cont_status = 0;
|
||||||
}
|
}
|
||||||
@@ -2736,8 +2740,7 @@ bool ins_compl_prep(int c)
|
|||||||
// Set "compl_get_longest" when finding the first matches.
|
// Set "compl_get_longest" when finding the first matches.
|
||||||
if (ctrl_x_mode_not_defined_yet()
|
if (ctrl_x_mode_not_defined_yet()
|
||||||
|| (ctrl_x_mode_normal() && !compl_started)) {
|
|| (ctrl_x_mode_normal() && !compl_started)) {
|
||||||
compl_get_longest = (get_cot_flags() & kOptCotFlagLongest) != 0
|
compl_get_longest = (get_cot_flags() & kOptCotFlagLongest) != 0;
|
||||||
&& !ins_compl_has_autocomplete();
|
|
||||||
compl_used_match = true;
|
compl_used_match = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6293,6 +6296,7 @@ int ins_complete(int c, bool enable_pum)
|
|||||||
void ins_compl_enable_autocomplete(void)
|
void ins_compl_enable_autocomplete(void)
|
||||||
{
|
{
|
||||||
compl_autocomplete = true;
|
compl_autocomplete = true;
|
||||||
|
compl_get_longest = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove (if needed) and show the popup menu
|
/// Remove (if needed) and show the popup menu
|
||||||
|
@@ -5984,7 +5984,7 @@ func Test_autocomplete_longest()
|
|||||||
call feedkeys("Go\<ESC>", 'tx')
|
call feedkeys("Go\<ESC>", 'tx')
|
||||||
call DoTest("f\<C-N>\<C-N>\<BS>\<BS>\<BS>\<BS>", 'foo', 3)
|
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
|
" takes precedence
|
||||||
%delete
|
%delete
|
||||||
set autocomplete completeopt+=longest,preinsert
|
set autocomplete completeopt+=longest,preinsert
|
||||||
@@ -6035,6 +6035,21 @@ func Test_autocomplete_longest()
|
|||||||
%delete _
|
%delete _
|
||||||
delfunc CheckUndo
|
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!
|
bw!
|
||||||
set cot& autocomplete&
|
set cot& autocomplete&
|
||||||
delfunc GetLine
|
delfunc GetLine
|
||||||
|
Reference in New Issue
Block a user