mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.1.1201: 'completefuzzycollect' does not handle dictionary correctly
Problem: 'completefuzzycollect' does not handle dictionary correctly
Solution: check for ctrl_x_mode_dictionary (glepnir)
closes: vim/vim#16867
587601671c
Cherry-pick a documentation fix from later.
Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
@@ -1526,17 +1526,18 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
find completion candidates instead of the standard prefix-based
|
find completion candidates instead of the standard prefix-based
|
||||||
matching. This option can contain the following values:
|
matching. This option can contain the following values:
|
||||||
|
|
||||||
keyword keywords in the current file |i_CTRL-X_CTRL-N|
|
keyword keywords in the current file |i_CTRL-X_CTRL-N|
|
||||||
keywords with the ".", "w", "b", "u", "U" and
|
keywords with flags ".", "w", |i_CTRL-N| |i_CTRL-P|
|
||||||
"k{dict}" flags in 'complete'. |i_CTRL-N| |i_CTRL-P|
|
"b", "u", "U" and "k{dict}" in 'complete'
|
||||||
|
keywords in 'dictionary' |i_CTRL-X_CTRL-K|
|
||||||
|
|
||||||
files file names |i_CTRL-X_CTRL-F|
|
files file names |i_CTRL-X_CTRL-F|
|
||||||
|
|
||||||
whole_line whole lines |i_CTRL-X_CTRL-L|
|
whole_line whole lines |i_CTRL-X_CTRL-L|
|
||||||
|
|
||||||
When used with 'completeopt' "longest" option, fuzzy collection can
|
When using the 'completeopt' "longest" option value, fuzzy collection
|
||||||
identify the longest common string among the best fuzzy matches and
|
can identify the longest common string among the best fuzzy matches
|
||||||
automatically insert it.
|
and insert it automatically.
|
||||||
|
|
||||||
*'completeitemalign'* *'cia'*
|
*'completeitemalign'* *'cia'*
|
||||||
'completeitemalign' 'cia' string (default "abbr,kind,menu")
|
'completeitemalign' 'cia' string (default "abbr,kind,menu")
|
||||||
|
17
runtime/lua/vim/_meta/options.lua
generated
17
runtime/lua/vim/_meta/options.lua
generated
@@ -1050,17 +1050,18 @@ vim.bo.cfu = vim.bo.completefunc
|
|||||||
--- find completion candidates instead of the standard prefix-based
|
--- find completion candidates instead of the standard prefix-based
|
||||||
--- matching. This option can contain the following values:
|
--- matching. This option can contain the following values:
|
||||||
---
|
---
|
||||||
--- keyword keywords in the current file `i_CTRL-X_CTRL-N`
|
--- keyword keywords in the current file `i_CTRL-X_CTRL-N`
|
||||||
--- keywords with the ".", "w", "b", "u", "U" and
|
--- keywords with flags ".", "w", `i_CTRL-N` `i_CTRL-P`
|
||||||
--- "k{dict}" flags in 'complete'. `i_CTRL-N` `i_CTRL-P`
|
--- "b", "u", "U" and "k{dict}" in 'complete'
|
||||||
|
--- keywords in 'dictionary' `i_CTRL-X_CTRL-K`
|
||||||
---
|
---
|
||||||
--- files file names `i_CTRL-X_CTRL-F`
|
--- files file names `i_CTRL-X_CTRL-F`
|
||||||
---
|
---
|
||||||
--- whole_line whole lines `i_CTRL-X_CTRL-L`
|
--- whole_line whole lines `i_CTRL-X_CTRL-L`
|
||||||
---
|
---
|
||||||
--- When used with 'completeopt' "longest" option, fuzzy collection can
|
--- When using the 'completeopt' "longest" option value, fuzzy collection
|
||||||
--- identify the longest common string among the best fuzzy matches and
|
--- can identify the longest common string among the best fuzzy matches
|
||||||
--- automatically insert it.
|
--- and insert it automatically.
|
||||||
---
|
---
|
||||||
--- @type string
|
--- @type string
|
||||||
vim.o.completefuzzycollect = ""
|
vim.o.completefuzzycollect = ""
|
||||||
|
@@ -792,14 +792,13 @@ int ins_compl_add_infercase(char *str_arg, int len, bool icase, char *fname, Dir
|
|||||||
/// Check if ctrl_x_mode has been configured in 'completefuzzycollect'
|
/// Check if ctrl_x_mode has been configured in 'completefuzzycollect'
|
||||||
static bool cfc_has_mode(void)
|
static bool cfc_has_mode(void)
|
||||||
{
|
{
|
||||||
switch (ctrl_x_mode) {
|
if (ctrl_x_mode_normal() || ctrl_x_mode_dictionary()) {
|
||||||
case CTRL_X_NORMAL:
|
|
||||||
return (cfc_flags & kOptCfcFlagKeyword) != 0;
|
return (cfc_flags & kOptCfcFlagKeyword) != 0;
|
||||||
case CTRL_X_FILES:
|
} else if (ctrl_x_mode_files()) {
|
||||||
return (cfc_flags & kOptCfcFlagFiles) != 0;
|
return (cfc_flags & kOptCfcFlagFiles) != 0;
|
||||||
case CTRL_X_WHOLE_LINE:
|
} else if (ctrl_x_mode_whole_line()) {
|
||||||
return (cfc_flags & kOptCfcFlagWholeLine) != 0;
|
return (cfc_flags & kOptCfcFlagWholeLine) != 0;
|
||||||
default:
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1670,7 +1669,7 @@ static void ins_compl_files(int count, char **files, bool thesaurus, int flags,
|
|||||||
regmatch_T *regmatch, char *buf, Direction *dir)
|
regmatch_T *regmatch, char *buf, Direction *dir)
|
||||||
FUNC_ATTR_NONNULL_ARG(2, 7)
|
FUNC_ATTR_NONNULL_ARG(2, 7)
|
||||||
{
|
{
|
||||||
bool in_fuzzy_collect = cfc_has_mode() && ctrl_x_mode_normal();
|
bool in_fuzzy_collect = cfc_has_mode();
|
||||||
|
|
||||||
char *leader = in_fuzzy_collect ? ins_compl_leader() : NULL;
|
char *leader = in_fuzzy_collect ? ins_compl_leader() : NULL;
|
||||||
int leader_len = in_fuzzy_collect ? (int)ins_compl_leader_len() : 0;
|
int leader_len = in_fuzzy_collect ? (int)ins_compl_leader_len() : 0;
|
||||||
|
@@ -1472,17 +1472,18 @@ local options = {
|
|||||||
find completion candidates instead of the standard prefix-based
|
find completion candidates instead of the standard prefix-based
|
||||||
matching. This option can contain the following values:
|
matching. This option can contain the following values:
|
||||||
|
|
||||||
keyword keywords in the current file |i_CTRL-X_CTRL-N|
|
keyword keywords in the current file |i_CTRL-X_CTRL-N|
|
||||||
keywords with the ".", "w", "b", "u", "U" and
|
keywords with flags ".", "w", |i_CTRL-N| |i_CTRL-P|
|
||||||
"k{dict}" flags in 'complete'. |i_CTRL-N| |i_CTRL-P|
|
"b", "u", "U" and "k{dict}" in 'complete'
|
||||||
|
keywords in 'dictionary' |i_CTRL-X_CTRL-K|
|
||||||
|
|
||||||
files file names |i_CTRL-X_CTRL-F|
|
files file names |i_CTRL-X_CTRL-F|
|
||||||
|
|
||||||
whole_line whole lines |i_CTRL-X_CTRL-L|
|
whole_line whole lines |i_CTRL-X_CTRL-L|
|
||||||
|
|
||||||
When used with 'completeopt' "longest" option, fuzzy collection can
|
When using the 'completeopt' "longest" option value, fuzzy collection
|
||||||
identify the longest common string among the best fuzzy matches and
|
can identify the longest common string among the best fuzzy matches
|
||||||
automatically insert it.
|
and insert it automatically.
|
||||||
]=],
|
]=],
|
||||||
full_name = 'completefuzzycollect',
|
full_name = 'completefuzzycollect',
|
||||||
list = 'onecomma',
|
list = 'onecomma',
|
||||||
|
@@ -2988,8 +2988,17 @@ func Test_complete_fuzzy_collect()
|
|||||||
call feedkeys("Gofuzzy\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<CR>\<Esc>0", 'tx!')
|
call feedkeys("Gofuzzy\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<CR>\<Esc>0", 'tx!')
|
||||||
call assert_equal('completefuzzycollect', getline(line('.') - 1))
|
call assert_equal('completefuzzycollect', getline(line('.') - 1))
|
||||||
|
|
||||||
|
" keywords in 'dictonary'
|
||||||
|
call writefile(['hello', 'think'], 'test_dict.txt', 'D')
|
||||||
|
set dict=test_dict.txt
|
||||||
|
call feedkeys("Sh\<C-X>\<C-K>\<C-N>\<CR>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal('hello', getline(line('.') - 1))
|
||||||
|
call feedkeys("Sh\<C-X>\<C-K>\<C-N>\<C-N>\<CR>\<Esc>0", 'tx!')
|
||||||
|
call assert_equal('think', getline(line('.') - 1))
|
||||||
|
|
||||||
bw!
|
bw!
|
||||||
bw!
|
bw!
|
||||||
|
set dict&
|
||||||
set completeopt& cfc& cpt&
|
set completeopt& cfc& cpt&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user