From: zeertzjq Date: Tue, 5 May 2026 18:56:56 +0000 (+0000) Subject: patch 9.2.0442: completion: i_CTRL-X_CTRL-V doesn't use dict from customlist X-Git-Tag: v9.2.0442^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bfddbea47e1afa79ecd094040418abdba88bc83;p=thirdparty%2Fvim.git patch 9.2.0442: completion: i_CTRL-X_CTRL-V doesn't use dict from customlist 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 Signed-off-by: Christian Brabandt --- diff --git a/src/cmdexpand.c b/src/cmdexpand.c index c265ecbe7f..eb4f362b2b 100644 --- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -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) diff --git a/src/insexpand.c b/src/insexpand.c index a603ed7b08..bbb15b003e 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -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); + } } /* diff --git a/src/proto/cmdexpand.pro b/src/proto/cmdexpand.pro index 50383b98cc..67dff09ca4 100644 --- a/src/proto/cmdexpand.pro +++ b/src/proto/cmdexpand.pro @@ -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_1.dump b/src/testdir/dumps/Test_customlist_info_popup_01.dump similarity index 100% rename from src/testdir/dumps/Test_customlist_info_popup_1.dump rename to src/testdir/dumps/Test_customlist_info_popup_01.dump diff --git a/src/testdir/dumps/Test_customlist_info_popup_2.dump b/src/testdir/dumps/Test_customlist_info_popup_02.dump similarity index 100% rename from src/testdir/dumps/Test_customlist_info_popup_2.dump rename to src/testdir/dumps/Test_customlist_info_popup_02.dump diff --git a/src/testdir/dumps/Test_customlist_info_popup_3.dump b/src/testdir/dumps/Test_customlist_info_popup_03.dump similarity index 100% rename from src/testdir/dumps/Test_customlist_info_popup_3.dump rename to src/testdir/dumps/Test_customlist_info_popup_03.dump diff --git a/src/testdir/dumps/Test_customlist_info_popup_4.dump b/src/testdir/dumps/Test_customlist_info_popup_04.dump similarity index 100% rename from src/testdir/dumps/Test_customlist_info_popup_4.dump rename to src/testdir/dumps/Test_customlist_info_popup_04.dump diff --git a/src/testdir/dumps/Test_customlist_info_popup_5.dump b/src/testdir/dumps/Test_customlist_info_popup_05.dump similarity index 100% rename from src/testdir/dumps/Test_customlist_info_popup_5.dump rename to src/testdir/dumps/Test_customlist_info_popup_05.dump 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 index 0000000000..72324ff0a8 --- /dev/null +++ b/src/testdir/dumps/Test_customlist_info_popup_06.dump @@ -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 index 0000000000..f11f3ea9f1 --- /dev/null +++ b/src/testdir/dumps/Test_customlist_info_popup_07.dump @@ -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 index 0000000000..adbe3b71af --- /dev/null +++ b/src/testdir/dumps/Test_customlist_info_popup_08.dump @@ -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 index 0000000000..236c7dcd1e --- /dev/null +++ b/src/testdir/dumps/Test_customlist_info_popup_09.dump @@ -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 index 0000000000..5c07e54db1 --- /dev/null +++ b/src/testdir/dumps/Test_customlist_info_popup_10.dump @@ -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 index 0000000000..830dfcff04 --- /dev/null +++ b/src/testdir/dumps/Test_customlist_info_popup_11.dump @@ -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 diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index d58ff2b6d0..7b3449e2bd 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -4662,25 +4662,46 @@ func Test_customlist_dict_completion_info_popup() call term_sendkeys(buf, ":DictCmd \") 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, "\") 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, "\") 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, "\") 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, "\") 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, "\") + + " Tests for Insert mode i_CTRL-X_CTRL-V + call term_sendkeys(buf, "iDictCmd \\") + call VerifyScreenDump(buf, 'Test_customlist_info_popup_06', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_customlist_info_popup_07', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_customlist_info_popup_08', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_customlist_info_popup_09', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_customlist_info_popup_10', {}) + + " Starting another i_CTRL-X_CTRL-V completion should not leak memory + call term_sendkeys(buf, "\sign un\\") + call VerifyScreenDump(buf, 'Test_customlist_info_popup_11', {}) + call StopVimInTerminal(buf) endfunc diff --git a/src/version.c b/src/version.c index b64fd60b82..5dde38b7b4 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 442, /**/ 441, /**/