mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
Merge pull request #34429 from zeertzjq/vim-9.1.1447
vim-patch:9.1.{1447,1449}
This commit is contained in:
@@ -1339,14 +1339,16 @@ static int cp_compare_nearest(const void *a, const void *b)
|
|||||||
/// Set fuzzy score.
|
/// Set fuzzy score.
|
||||||
static void set_fuzzy_score(void)
|
static void set_fuzzy_score(void)
|
||||||
{
|
{
|
||||||
if (compl_leader.data != NULL && compl_leader.size > 0) {
|
if (!compl_first_match || compl_leader.data == NULL || compl_leader.size == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
compl_T *comp = compl_first_match;
|
compl_T *comp = compl_first_match;
|
||||||
do {
|
do {
|
||||||
comp->cp_score = fuzzy_match_str(comp->cp_str.data, compl_leader.data);
|
comp->cp_score = fuzzy_match_str(comp->cp_str.data, compl_leader.data);
|
||||||
comp = comp->cp_next;
|
comp = comp->cp_next;
|
||||||
} while (comp != NULL && !is_first_match(comp));
|
} while (comp != NULL && !is_first_match(comp));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Sort completion matches, excluding the node that contains the leader.
|
/// Sort completion matches, excluding the node that contains the leader.
|
||||||
static void sort_compl_match_list(MergeSortCompareFunc compare)
|
static void sort_compl_match_list(MergeSortCompareFunc compare)
|
||||||
|
@@ -285,7 +285,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i
|
|||||||
// for cmdline pum, no need for context lines unless target_win is set
|
// for cmdline pum, no need for context lines unless target_win is set
|
||||||
context_lines = 0;
|
context_lines = 0;
|
||||||
} else {
|
} else {
|
||||||
// Leave two lines of context if possible
|
// Leave three lines of context if possible
|
||||||
validate_cheight(target_win);
|
validate_cheight(target_win);
|
||||||
int cline_visible_offset = target_win->w_cline_row +
|
int cline_visible_offset = target_win->w_cline_row +
|
||||||
target_win->w_cline_height - target_win->w_wrow;
|
target_win->w_cline_height - target_win->w_wrow;
|
||||||
|
@@ -4835,4 +4835,29 @@ func Test_complete_unloaded_buf_refresh_always()
|
|||||||
delfunc TestComplete
|
delfunc TestComplete
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_complete_fuzzy_omnifunc_backspace()
|
||||||
|
let g:do_complete = v:false
|
||||||
|
func Omni_test(findstart, base)
|
||||||
|
if a:findstart
|
||||||
|
let g:do_complete = !g:do_complete
|
||||||
|
endif
|
||||||
|
if g:do_complete
|
||||||
|
return a:findstart ? 0 : [#{word: a:base .. 'def'}, #{word: a:base .. 'ghi'}]
|
||||||
|
endif
|
||||||
|
return a:findstart ? -3 : {}
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
new
|
||||||
|
redraw " need this to prevent NULL dereference in Nvim
|
||||||
|
setlocal omnifunc=Omni_test
|
||||||
|
setlocal completeopt=menuone,fuzzy,noinsert
|
||||||
|
call setline(1, 'abc')
|
||||||
|
call feedkeys("A\<C-X>\<C-O>\<BS>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal('ab', getline(1))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
delfunc Omni_test
|
||||||
|
unlet g:do_complete
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
|
||||||
|
Reference in New Issue
Block a user