From fe1d3c8af764831aa51a8922ce24a7cfd9e6129d Mon Sep 17 00:00:00 2001 From: Girish Palya Date: Sun, 13 Jul 2025 16:53:53 +0200 Subject: [PATCH] patch 9.1.1539: completion: messages don't respect 'shm' setting Problem: completion: messages don't respect 'shm' setting Solution: Turn off completion messages when 'shortmess' includes "c" (Girish Palya). `:set shortmess+=c` is intended to reduce noise during completion by suppressing messages. Previously, some completion messages still appeared regardless of this setting. This change ensures that **all** completion-related messages are suppressed when `'c'` is present in `'shortmess'`. Not entirely sure if the original behavior was intentional. If there's a reason certain messages were always shown, feel free to close this without merging. closes: #17737 Signed-off-by: Girish Palya Signed-off-by: Christian Brabandt --- src/insexpand.c | 30 ++++++++++++------- .../dumps/Test_shortmess_complmsg_1.dump | 12 ++++++++ .../dumps/Test_shortmess_complmsg_2.dump | 12 ++++++++ src/testdir/test_ins_complete.vim | 21 +++++++++++++ src/version.c | 2 ++ 5 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 src/testdir/dumps/Test_shortmess_complmsg_1.dump create mode 100644 src/testdir/dumps/Test_shortmess_complmsg_2.dump diff --git a/src/insexpand.c b/src/insexpand.c index 7e3de60e84..84690e5883 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -6600,7 +6600,8 @@ ins_compl_start(void) if (compl_status_adding()) { - edit_submode_pre = (char_u *)_(" Adding"); + if (!shortmess(SHM_COMPLETIONMENU)) + edit_submode_pre = (char_u *)_(" Adding"); if (ctrl_x_mode_line_or_eval()) { // Insert a new line, keep indentation but ignore 'comments'. @@ -6627,10 +6628,13 @@ ins_compl_start(void) compl_startpos.col = compl_col; } - if (compl_cont_status & CONT_LOCAL) - edit_submode = (char_u *)_(ctrl_x_msgs[CTRL_X_LOCAL_MSG]); - else - edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode)); + if (!shortmess(SHM_COMPLETIONMENU)) + { + if (compl_cont_status & CONT_LOCAL) + edit_submode = (char_u *)_(ctrl_x_msgs[CTRL_X_LOCAL_MSG]); + else + edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode)); + } // If any of the original typed text has been changed we need to fix // the redo buffer. @@ -6655,11 +6659,14 @@ ins_compl_start(void) // showmode might reset the internal line pointers, so it must // be called before line = ml_get(), or when this address is no // longer needed. -- Acevedo. - edit_submode_extra = (char_u *)_("-- Searching..."); - edit_submode_highl = HLF_COUNT; - showmode(); - edit_submode_extra = NULL; - out_flush(); + if (!shortmess(SHM_COMPLETIONMENU)) + { + edit_submode_extra = (char_u *)_("-- Searching..."); + edit_submode_highl = HLF_COUNT; + showmode(); + edit_submode_extra = NULL; + out_flush(); + } return OK; } @@ -6821,7 +6828,8 @@ ins_complete(int c, int enable_pum) else compl_cont_status &= ~CONT_S_IPOS; - ins_compl_show_statusmsg(); + if (!shortmess(SHM_COMPLETIONMENU)) + ins_compl_show_statusmsg(); // Show the popup menu, unless we got interrupted. if (enable_pum && !compl_interrupted) diff --git a/src/testdir/dumps/Test_shortmess_complmsg_1.dump b/src/testdir/dumps/Test_shortmess_complmsg_1.dump new file mode 100644 index 0000000000..0b1a0d99c9 --- /dev/null +++ b/src/testdir/dumps/Test_shortmess_complmsg_1.dump @@ -0,0 +1,12 @@ +|h+0&#ffffff0|e|l@1|o| @69 +|h|u|l@1|o| @69 +|h|e@2| @70 +|h|e|l@1|o> @69 +|h+0#0000001#e0e0e08|e|l@1|o| @9| +0#4040ff13#ffffff0@59 +|h+0#0000001#ffd7ff255|u|l@1|o| @9| +0#4040ff13#ffffff0@59 +|h+0#0000001#ffd7ff255|e@2| @10| +0#4040ff13#ffffff0@59 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|-+2#0000000&@1| |K|e|y|w|o|r|d| |c|o|m|p|l|e|t|i|o|n| |(|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |3| +0#0000000&@33 diff --git a/src/testdir/dumps/Test_shortmess_complmsg_2.dump b/src/testdir/dumps/Test_shortmess_complmsg_2.dump new file mode 100644 index 0000000000..542733b306 --- /dev/null +++ b/src/testdir/dumps/Test_shortmess_complmsg_2.dump @@ -0,0 +1,12 @@ +|h+0&#ffffff0|e|l@1|o| @69 +|h|u|l@1|o| @69 +|h|e@2| @70 +|h|e|l@1|o> @69 +|h+0#0000001#e0e0e08|e|l@1|o| @9| +0#4040ff13#ffffff0@59 +|h+0#0000001#ffd7ff255|u|l@1|o| @9| +0#4040ff13#ffffff0@59 +|h+0#0000001#ffd7ff255|e@2| @10| +0#4040ff13#ffffff0@59 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@62 diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index 9ee7876c21..1573fbee00 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -4976,4 +4976,25 @@ func Test_nonkeyword_trigger() unlet g:CallCount endfunc +" Test that option shortmess=c turns off completion messages +func Test_shortmess() + CheckScreendump + + let lines =<< trim END + call setline(1, ['hello', 'hullo', 'heee']) + END + + call writefile(lines, 'Xpumscript', 'D') + let buf = RunVimInTerminal('-S Xpumscript', #{rows: 12}) + call term_sendkeys(buf, "Goh\") + call TermWait(buf, 200) + call VerifyScreenDump(buf, 'Test_shortmess_complmsg_1', {}) + call term_sendkeys(buf, "\:set shm+=c\") + call term_sendkeys(buf, "Sh\") + call TermWait(buf, 200) + call VerifyScreenDump(buf, 'Test_shortmess_complmsg_2', {}) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab nofoldenable diff --git a/src/version.c b/src/version.c index f40d51075c..f63b167898 100644 --- a/src/version.c +++ b/src/version.c @@ -719,6 +719,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1539, /**/ 1538, /**/