]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0442: completion: i_CTRL-X_CTRL-V doesn't use dict from customlist v9.2.0442
authorzeertzjq <zeertzjq@outlook.com>
Tue, 5 May 2026 18:56:56 +0000 (18:56 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 5 May 2026 18:56:56 +0000 (18:56 +0000)
Problem:  Completion with i_CTRL-X_CTRL-V doesn't use dict from cmdline
          "customlist" completion.
Solution: Include abbr/kind/menu/info in the completion items
          (zeertzjq).

closes: #20139

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
16 files changed:
src/cmdexpand.c
src/insexpand.c
src/proto/cmdexpand.pro
src/testdir/dumps/Test_customlist_info_popup_01.dump [moved from src/testdir/dumps/Test_customlist_info_popup_1.dump with 100% similarity]
src/testdir/dumps/Test_customlist_info_popup_02.dump [moved from src/testdir/dumps/Test_customlist_info_popup_2.dump with 100% similarity]
src/testdir/dumps/Test_customlist_info_popup_03.dump [moved from src/testdir/dumps/Test_customlist_info_popup_3.dump with 100% similarity]
src/testdir/dumps/Test_customlist_info_popup_04.dump [moved from src/testdir/dumps/Test_customlist_info_popup_4.dump with 100% similarity]
src/testdir/dumps/Test_customlist_info_popup_05.dump [moved from src/testdir/dumps/Test_customlist_info_popup_5.dump with 100% similarity]
src/testdir/dumps/Test_customlist_info_popup_06.dump [new file with mode: 0644]
src/testdir/dumps/Test_customlist_info_popup_07.dump [new file with mode: 0644]
src/testdir/dumps/Test_customlist_info_popup_08.dump [new file with mode: 0644]
src/testdir/dumps/Test_customlist_info_popup_09.dump [new file with mode: 0644]
src/testdir/dumps/Test_customlist_info_popup_10.dump [new file with mode: 0644]
src/testdir/dumps/Test_customlist_info_popup_11.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c

index c265ecbe7f3b5165a876cc8209ce9c2dfcf4dbd0..eb4f362b2bd209afed7ba7ec6d6768b1acb9de18 100644 (file)
@@ -1027,7 +1027,7 @@ find_longest_match(expand_T *xp, int options)
     return ss;
 }
 
-    static void
+    void
 free_xp_files_extra(expand_T *xp, int numfiles)
 {
     if (xp->xp_files_abbr != NULL)
index a603ed7b08b02c02272942f053be6986ea4eb165..bbb15b003ea5488e0e5a9fb01656405e7c631cf9 100644 (file)
@@ -4801,7 +4801,32 @@ get_next_cmdline_completion(void)
 
     if (expand_cmdline(&compl_xp, compl_pattern.string,
                (int)compl_pattern.length, &num_matches, &matches) == EXPAND_OK)
-       ins_compl_add_matches(num_matches, matches, FALSE);
+    {
+       int             add_r = OK;
+       int             dir = compl_direction;
+
+       for (int i = 0; i < num_matches && add_r != FAIL; i++)
+       {
+           char_u      *(cptext[CPT_COUNT]) = {NULL, NULL, NULL, NULL};
+
+           if (compl_xp.xp_files_abbr != NULL)
+               cptext[CPT_ABBR] = compl_xp.xp_files_abbr[i];
+           if (compl_xp.xp_files_kind != NULL)
+               cptext[CPT_KIND] = compl_xp.xp_files_kind[i];
+           if (compl_xp.xp_files_menu != NULL)
+               cptext[CPT_MENU] = compl_xp.xp_files_menu[i];
+           if (compl_xp.xp_files_info != NULL)
+               cptext[CPT_INFO] = compl_xp.xp_files_info[i];
+
+           add_r = ins_compl_add(matches[i], -1, NULL, cptext, NULL, dir,
+                   CP_FAST, FALSE, NULL, FUZZY_SCORE_NONE);
+           if (add_r == OK)
+               // if dir was BACKWARD then honor it just once
+               dir = FORWARD;
+       }
+       FreeWild(num_matches, matches);
+       free_xp_files_extra(&compl_xp, num_matches);
+    }
 }
 
 /*
index 50383b98cc1133572c32d057dc47e006f432f4a1..67dff09ca41bb0b90e535d8171d8d7837c2a412e 100644 (file)
@@ -8,6 +8,7 @@ void cmdline_pum_cleanup(cmdline_info_T *cclp);
 int cmdline_compl_startcol(void);
 char_u *cmdline_compl_pattern(void);
 int cmdline_compl_is_fuzzy(void);
+void free_xp_files_extra(expand_T *xp, int numfiles);
 char_u *ExpandOne(expand_T *xp, char_u *str, char_u *orig, int options, int mode);
 void ExpandInit(expand_T *xp);
 void ExpandCleanup(expand_T *xp);
diff --git a/src/testdir/dumps/Test_customlist_info_popup_06.dump b/src/testdir/dumps/Test_customlist_info_popup_06.dump
new file mode 100644 (file)
index 0000000..72324ff
--- /dev/null
@@ -0,0 +1,12 @@
+|D+0&#ffffff0|i|c|t|C|m|d| |a|p@1|l|e> @13|╔+0#0000001#e0e0e08|═@12|X| +0#0000000#ffffff0@32
+|~+0#4040ff13&| @5| +0#0000001#e0e0e08|a|p@1|l|e| @1|f| |f|r|u|i|t| @4|║| |A| |r|e|d| |f|r|u|i|t| |║| +0#4040ff13#ffffff0@32
+|~| @5| +0#0000001#ffd7ff255|b|a|n|a|n|a| |f| |f|r|u|i|t| @4|╚+0&#e0e0e08|═@12|⇲| +0#4040ff13#ffffff0@32
+|~| @5| +0#0000001#ffd7ff255|c|a|r@1|o|t| |v| |v|e|g|e|t|a|b|l|e| | +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#ffd7ff255|p|l|a|i|n| @13| +0#4040ff13#ffffff0@47
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |C|o|m@1|a|n|d|-|l|i|n|e| |c|o|m|p|l|e|t|i|o|n| |(|^|V|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@26
diff --git a/src/testdir/dumps/Test_customlist_info_popup_07.dump b/src/testdir/dumps/Test_customlist_info_popup_07.dump
new file mode 100644 (file)
index 0000000..f11f3ea
--- /dev/null
@@ -0,0 +1,12 @@
+|D+0&#ffffff0|i|c|t|C|m|d| |b|a|n|a|n|a> @60
+|~+0#4040ff13&| @5| +0#0000001#ffd7ff255|a|p@1|l|e| @1|f| |f|r|u|i|t| @4|╔+0&#e0e0e08|═@15|X| +0#4040ff13#ffffff0@29
+|~| @5| +0#0000001#e0e0e08|b|a|n|a|n|a| |f| |f|r|u|i|t| @4|║| |A| |y|e|l@1|o|w| |f|r|u|i|t| |║| +0#4040ff13#ffffff0@29
+|~| @5| +0#0000001#ffd7ff255|c|a|r@1|o|t| |v| |v|e|g|e|t|a|b|l|e| |╚+0&#e0e0e08|═@15|⇲| +0#4040ff13#ffffff0@29
+|~| @5| +0#0000001#ffd7ff255|p|l|a|i|n| @13| +0#4040ff13#ffffff0@47
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |C|o|m@1|a|n|d|-|l|i|n|e| |c|o|m|p|l|e|t|i|o|n| |(|^|V|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |2| |o|f| |4| +0#0000000&@26
diff --git a/src/testdir/dumps/Test_customlist_info_popup_08.dump b/src/testdir/dumps/Test_customlist_info_popup_08.dump
new file mode 100644 (file)
index 0000000..adbe3b7
--- /dev/null
@@ -0,0 +1,12 @@
+|D+0&#ffffff0|i|c|t|C|m|d| |c|a|r@1|o|t> @60
+|~+0#4040ff13&| @5| +0#0000001#ffd7ff255|a|p@1|l|e| @1|f| |f|r|u|i|t| @4| +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#ffd7ff255|b|a|n|a|n|a| |f| |f|r|u|i|t| @4|╔+0&#e0e0e08|═@20|X| +0#4040ff13#ffffff0@24
+|~| @5| +0#0000001#e0e0e08|c|a|r@1|o|t| |v| |v|e|g|e|t|a|b|l|e| |║| |A|n| |o|r|a|n|g|e| |v|e|g|e|t|a|b|l|e| |║| +0#4040ff13#ffffff0@24
+|~| @5| +0#0000001#ffd7ff255|p|l|a|i|n| @13|╚+0&#e0e0e08|═@20|⇲| +0#4040ff13#ffffff0@24
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |C|o|m@1|a|n|d|-|l|i|n|e| |c|o|m|p|l|e|t|i|o|n| |(|^|V|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |3| |o|f| |4| +0#0000000&@26
diff --git a/src/testdir/dumps/Test_customlist_info_popup_09.dump b/src/testdir/dumps/Test_customlist_info_popup_09.dump
new file mode 100644 (file)
index 0000000..236c7dc
--- /dev/null
@@ -0,0 +1,12 @@
+|D+0&#ffffff0|i|c|t|C|m|d| |p|l|a|i|n> @61
+|~+0#4040ff13&| @5| +0#0000001#ffd7ff255|a|p@1|l|e| @1|f| |f|r|u|i|t| @4| +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#ffd7ff255|b|a|n|a|n|a| |f| |f|r|u|i|t| @4| +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#ffd7ff255|c|a|r@1|o|t| |v| |v|e|g|e|t|a|b|l|e| | +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#e0e0e08|p|l|a|i|n| @13| +0#4040ff13#ffffff0@47
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |C|o|m@1|a|n|d|-|l|i|n|e| |c|o|m|p|l|e|t|i|o|n| |(|^|V|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |4| |o|f| |4| +0#0000000&@26
diff --git a/src/testdir/dumps/Test_customlist_info_popup_10.dump b/src/testdir/dumps/Test_customlist_info_popup_10.dump
new file mode 100644 (file)
index 0000000..5c07e54
--- /dev/null
@@ -0,0 +1,12 @@
+|D+0&#ffffff0|i|c|t|C|m|d| > @66
+|~+0#4040ff13&| @5| +0#0000001#ffd7ff255|a|p@1|l|e| @1|f| |f|r|u|i|t| @4| +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#ffd7ff255|b|a|n|a|n|a| |f| |f|r|u|i|t| @4| +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#ffd7ff255|c|a|r@1|o|t| |v| |v|e|g|e|t|a|b|l|e| | +0#4040ff13#ffffff0@47
+|~| @5| +0#0000001#ffd7ff255|p|l|a|i|n| @13| +0#4040ff13#ffffff0@47
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |C|o|m@1|a|n|d|-|l|i|n|e| |c|o|m|p|l|e|t|i|o|n| |(|^|V|^|N|^|P|)| |B+0#e000002&|a|c|k| |a|t| |o|r|i|g|i|n|a|l| +0#0000000&@22
diff --git a/src/testdir/dumps/Test_customlist_info_popup_11.dump b/src/testdir/dumps/Test_customlist_info_popup_11.dump
new file mode 100644 (file)
index 0000000..830dfcf
--- /dev/null
@@ -0,0 +1,12 @@
+|s+0&#ffffff0|i|g|n| |u|n|d|e|f|i|n|e> @61
+|~+0#4040ff13&| @2| +0#0000001#e0e0e08|u|n|d|e|f|i|n|e| @6| +0#4040ff13#ffffff0@54
+|~| @2| +0#0000001#ffd7ff255|u|n|p|l|a|c|e| @7| +0#4040ff13#ffffff0@54
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |C|o|m@1|a|n|d|-|l|i|n|e| |c|o|m|p|l|e|t|i|o|n| |(|^|V|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |2| +0#0000000&@26
index d58ff2b6d00efdc921f9b7c13a26313933909c40..7b3449e2bd2fe724a24d14eff78b5c110f07d5c8 100644 (file)
@@ -4662,25 +4662,46 @@ func Test_customlist_dict_completion_info_popup()
 
   call term_sendkeys(buf, ":DictCmd \<Tab>")
   call WaitForTermCurPosAndLinesToMatch(buf, [rows, (strlen(':DictCmd apple') + 1)], g:test_timeout, ((rows - 4), 'A red fruit'))
-  call VerifyScreenDump(buf, 'Test_customlist_info_popup_1', {})
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_01', {})
 
   call term_sendkeys(buf, "\<Tab>")
   call WaitForTermCurPosAndLinesToMatch(buf, [rows, (strlen(':DictCmd banana') + 1)], g:test_timeout, ((rows - 3), 'A yellow fruit'))
-  call VerifyScreenDump(buf, 'Test_customlist_info_popup_2', {})
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_02', {})
 
   call term_sendkeys(buf, "\<Tab>")
   call WaitForTermCurPosAndLinesToMatch(buf, [rows, (strlen(':DictCmd carrot') + 1)], g:test_timeout, ((rows - 2), 'An orange vegetable'))
-  call VerifyScreenDump(buf, 'Test_customlist_info_popup_3', {})
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_03', {})
 
   call term_sendkeys(buf, "\<Tab>")
   call WaitForTermCurPosAndLinesToMatch(buf, [rows, (strlen(':DictCmd plain') + 1)], g:test_timeout, ((rows - 1), '^\~\s\+plain\s\+$'))
-  call VerifyScreenDump(buf, 'Test_customlist_info_popup_4', {})
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_04', {})
 
   call term_sendkeys(buf, "\<Tab>")
   call WaitForTermCurPosAndLinesToMatch(buf, [rows, (strlen(':DictCmd ') + 1)], g:test_timeout)
-  call VerifyScreenDump(buf, 'Test_customlist_info_popup_5', {})
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_05', {})
 
   call term_sendkeys(buf, "\<Esc>")
+
+  " Tests for Insert mode i_CTRL-X_CTRL-V
+  call term_sendkeys(buf, "iDictCmd \<C-X>\<C-V>")
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_06', {})
+
+  call term_sendkeys(buf, "\<C-N>")
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_07', {})
+
+  call term_sendkeys(buf, "\<C-N>")
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_08', {})
+
+  call term_sendkeys(buf, "\<C-N>")
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_09', {})
+
+  call term_sendkeys(buf, "\<C-N>")
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_10', {})
+
+  " Starting another i_CTRL-X_CTRL-V completion should not leak memory
+  call term_sendkeys(buf, "\<C-U>sign un\<C-X>\<C-V>")
+  call VerifyScreenDump(buf, 'Test_customlist_info_popup_11', {})
+
   call StopVimInTerminal(buf)
 endfunc
 
index b64fd60b8249dfa8cad2c7d16288505ec5f59cc3..5dde38b7b4ca71c942ae4558c771a0f14bd320aa 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    442,
 /**/
     441,
 /**/