]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1539: completion: messages don't respect 'shm' setting v9.1.1539
authorGirish Palya <girishji@gmail.com>
Sun, 13 Jul 2025 14:53:53 +0000 (16:53 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 13 Jul 2025 14:53:53 +0000 (16:53 +0200)
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 <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/testdir/dumps/Test_shortmess_complmsg_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_shortmess_complmsg_2.dump [new file with mode: 0644]
src/testdir/test_ins_complete.vim
src/version.c

index 7e3de60e846060917700d38c3fc551ded3e283fb..84690e5883e71231e41833f0d106786e70bad551 100644 (file)
@@ -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 (file)
index 0000000..0b1a0d9
--- /dev/null
@@ -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 (file)
index 0000000..542733b
--- /dev/null
@@ -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
index 9ee7876c219c6d5cf7fd5f6a36ee441c9ae81fba..1573fbee009319a38fb701688a94cd9f0e0530be 100644 (file)
@@ -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\<C-N>")
+  call TermWait(buf, 200)
+  call VerifyScreenDump(buf, 'Test_shortmess_complmsg_1', {})
+  call term_sendkeys(buf, "\<ESC>:set shm+=c\<CR>")
+  call term_sendkeys(buf, "Sh\<C-N>")
+  call TermWait(buf, 200)
+  call VerifyScreenDump(buf, 'Test_shortmess_complmsg_2', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
index f40d51075c295d85cb0b7c75e8c90624d14ca216..f63b167898f331dd0e4fa2a5557892488789af66 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1539,
 /**/
     1538,
 /**/