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: #16867
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/insexpand.c b/src/insexpand.c
index 35d20d0..49c7ee2 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -764,17 +764,14 @@
static int
cfc_has_mode(void)
{
- switch (ctrl_x_mode)
- {
- case CTRL_X_NORMAL:
- return (cfc_flags & CFC_KEYWORD) != 0;
- case CTRL_X_FILES:
- return (cfc_flags & CFC_FILES) != 0;
- case CTRL_X_WHOLE_LINE:
- return (cfc_flags & CFC_WHOLELINE) != 0;
- default:
- return FALSE;
- }
+ if (ctrl_x_mode_normal() || ctrl_x_mode_dictionary())
+ return (cfc_flags & CFC_KEYWORD) != 0;
+ else if (ctrl_x_mode_files())
+ return (cfc_flags & CFC_FILES) != 0;
+ else if (ctrl_x_mode_whole_line())
+ return (cfc_flags & CFC_WHOLELINE) != 0;
+ else
+ return FALSE;
}
/*
@@ -1792,7 +1789,7 @@
int add_r;
char_u *leader = NULL;
int leader_len = 0;
- int in_fuzzy_collect = cfc_has_mode() && ctrl_x_mode_normal();
+ int in_fuzzy_collect = cfc_has_mode();
int score = 0;
int len = 0;
char_u *line_end = NULL;
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index e2a69f3..5d0e540 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -2955,8 +2955,17 @@
call feedkeys("Gofuzzy\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<CR>\<Esc>0", 'tx!')
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!
+ set dict&
set completeopt& cfc& cpt&
endfunc
diff --git a/src/version.c b/src/version.c
index f65999a..b9fcedc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1201,
+/**/
1200,
/**/
1199,