mirror of
https://github.com/neovim/neovim.git
synced 2025-11-07 11:14:26 +00:00
Merge pull request #20322 from zeertzjq/vim-9.0.0567
vim-patch:9.0.{0567,0572}: 'completeopt' "longest" is not used for complete()
This commit is contained in:
@@ -199,6 +199,8 @@ static bool compl_no_insert = false; ///< false: select & insert
|
|||||||
///< true: noinsert
|
///< true: noinsert
|
||||||
static bool compl_no_select = false; ///< false: select & insert
|
static bool compl_no_select = false; ///< false: select & insert
|
||||||
///< true: noselect
|
///< true: noselect
|
||||||
|
static bool compl_longest = false; ///< false: insert full match
|
||||||
|
///< true: insert longest prefix
|
||||||
|
|
||||||
/// Selected one of the matches. When false the match was edited or using the
|
/// Selected one of the matches. When false the match was edited or using the
|
||||||
/// longest common string.
|
/// longest common string.
|
||||||
@@ -1006,12 +1008,16 @@ void completeopt_was_set(void)
|
|||||||
{
|
{
|
||||||
compl_no_insert = false;
|
compl_no_insert = false;
|
||||||
compl_no_select = false;
|
compl_no_select = false;
|
||||||
|
compl_longest = false;
|
||||||
if (strstr(p_cot, "noselect") != NULL) {
|
if (strstr(p_cot, "noselect") != NULL) {
|
||||||
compl_no_select = true;
|
compl_no_select = true;
|
||||||
}
|
}
|
||||||
if (strstr(p_cot, "noinsert") != NULL) {
|
if (strstr(p_cot, "noinsert") != NULL) {
|
||||||
compl_no_insert = true;
|
compl_no_insert = true;
|
||||||
}
|
}
|
||||||
|
if (strstr(p_cot, "longest") != NULL) {
|
||||||
|
compl_longest = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "compl_match_array" points the currently displayed list of entries in the
|
/// "compl_match_array" points the currently displayed list of entries in the
|
||||||
@@ -2103,7 +2109,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 = (strstr(p_cot, "longest") != NULL);
|
compl_get_longest = compl_longest;
|
||||||
compl_used_match = true;
|
compl_used_match = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2420,6 +2426,7 @@ static void set_completion(colnr_T startcol, list_T *list)
|
|||||||
}
|
}
|
||||||
ins_compl_clear();
|
ins_compl_clear();
|
||||||
ins_compl_free();
|
ins_compl_free();
|
||||||
|
compl_get_longest = compl_longest;
|
||||||
|
|
||||||
compl_direction = FORWARD;
|
compl_direction = FORWARD;
|
||||||
if (startcol > curwin->w_cursor.col) {
|
if (startcol > curwin->w_cursor.col) {
|
||||||
@@ -2449,9 +2456,10 @@ static void set_completion(colnr_T startcol, list_T *list)
|
|||||||
int save_w_leftcol = curwin->w_leftcol;
|
int save_w_leftcol = curwin->w_leftcol;
|
||||||
|
|
||||||
compl_curr_match = compl_first_match;
|
compl_curr_match = compl_first_match;
|
||||||
if (compl_no_insert || compl_no_select) {
|
bool no_select = compl_no_select || compl_longest;
|
||||||
|
if (compl_no_insert || no_select) {
|
||||||
ins_complete(K_DOWN, false);
|
ins_complete(K_DOWN, false);
|
||||||
if (compl_no_select) {
|
if (no_select) {
|
||||||
ins_complete(K_UP, false);
|
ins_complete(K_UP, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -702,6 +702,27 @@ func Test_recursive_complete_func()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for using complete() with completeopt+=longest
|
||||||
|
func Test_complete_with_longest()
|
||||||
|
new
|
||||||
|
inoremap <buffer> <f3> <cmd>call complete(1, ["iaax", "iaay", "iaaz"])<cr>
|
||||||
|
|
||||||
|
" default: insert first match
|
||||||
|
set completeopt&
|
||||||
|
call setline(1, ['i'])
|
||||||
|
exe "normal Aa\<f3>\<esc>"
|
||||||
|
call assert_equal('iaax', getline(1))
|
||||||
|
|
||||||
|
" with longest: insert longest prefix
|
||||||
|
set completeopt+=longest
|
||||||
|
call setline(1, ['i'])
|
||||||
|
exe "normal Aa\<f3>\<esc>"
|
||||||
|
call assert_equal('iaa', getline(1))
|
||||||
|
set completeopt&
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" Test for completing words following a completed word in a line
|
" Test for completing words following a completed word in a line
|
||||||
func Test_complete_wrapscan()
|
func Test_complete_wrapscan()
|
||||||
" complete words from another buffer
|
" complete words from another buffer
|
||||||
@@ -1256,7 +1277,7 @@ endfunc
|
|||||||
" A mapping is not used for the key after CTRL-X.
|
" A mapping is not used for the key after CTRL-X.
|
||||||
func Test_no_mapping_for_ctrl_x_key()
|
func Test_no_mapping_for_ctrl_x_key()
|
||||||
new
|
new
|
||||||
inoremap <C-K> <Cmd>let was_mapped = 'yes'<CR>
|
inoremap <buffer> <C-K> <Cmd>let was_mapped = 'yes'<CR>
|
||||||
setlocal dictionary=README.txt
|
setlocal dictionary=README.txt
|
||||||
call feedkeys("aexam\<C-X>\<C-K> ", 'xt')
|
call feedkeys("aexam\<C-X>\<C-K> ", 'xt')
|
||||||
call assert_equal('example ', getline(1))
|
call assert_equal('example ', getline(1))
|
||||||
|
|||||||
Reference in New Issue
Block a user