commit f487ae90cfc4dd20c3289280dd8b496c5aa2316a
parent 96ec4db3e9739053642b7b5a5c8a94517e52ad25
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 14 Jul 2025 06:53:40 +0800
vim-patch:9.1.1539: completion: messages don't respect 'shm' setting (#34923)
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: vim/vim#17737
https://github.com/vim/vim/commit/fe1d3c8af764831aa51a8922ce24a7cfd9e6129d
Co-authored-by: Girish Palya <girishji@gmail.com>
Diffstat:
3 files changed, 69 insertions(+), 11 deletions(-)
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
@@ -5632,7 +5632,9 @@ static int ins_compl_start(void)
}
if (compl_status_adding()) {
- edit_submode_pre = _(" Adding");
+ if (!shortmess(SHM_COMPLETIONMENU)) {
+ edit_submode_pre = _(" Adding");
+ }
if (ctrl_x_mode_line_or_eval()) {
// Insert a new line, keep indentation but ignore 'comments'.
char *old = curbuf->b_p_com;
@@ -5654,10 +5656,12 @@ static int ins_compl_start(void)
compl_startpos.col = compl_col;
}
- if (compl_cont_status & CONT_LOCAL) {
- edit_submode = _(ctrl_x_msgs[CTRL_X_LOCAL_MSG]);
- } else {
- edit_submode = _(CTRL_X_MSG(ctrl_x_mode));
+ if (!shortmess(SHM_COMPLETIONMENU)) {
+ if (compl_cont_status & CONT_LOCAL) {
+ edit_submode = _(ctrl_x_msgs[CTRL_X_LOCAL_MSG]);
+ } else {
+ edit_submode = _(CTRL_X_MSG(ctrl_x_mode));
+ }
}
// If any of the original typed text has been changed we need to fix
@@ -5685,11 +5689,13 @@ static int 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 = _("-- Searching...");
- edit_submode_highl = HLF_COUNT;
- showmode();
- edit_submode_extra = NULL;
- ui_flush();
+ if (!shortmess(SHM_COMPLETIONMENU)) {
+ edit_submode_extra = _("-- Searching...");
+ edit_submode_highl = HLF_COUNT;
+ showmode();
+ edit_submode_extra = NULL;
+ ui_flush();
+ }
return OK;
}
@@ -5822,7 +5828,9 @@ int ins_complete(int c, bool enable_pum)
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/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua
@@ -1373,4 +1373,33 @@ describe('completion', function()
{5:-- Keyword completion (^N^P) The only match} |
]])
end)
+
+ -- oldtest: Test_shortmess()
+ it('shortmess+=c turns off completion messages', function()
+ command([[call setline(1, ['hello', 'hullo', 'heee'])]])
+ feed('Goh<C-N>')
+ screen:expect([[
+ hello |
+ hullo |
+ heee |
+ hello^ |
+ {12:hello }{1: }|
+ {4:hullo }{1: }|
+ {4:heee }{1: }|
+ {5:-- Keyword completion (^N^P) }{6:match 1 of 3} |
+ ]])
+ feed('<Esc>')
+ command('set shm+=c')
+ feed('Sh<C-N>')
+ screen:expect([[
+ hello |
+ hullo |
+ heee |
+ hello^ |
+ {12:hello }{1: }|
+ {4:hullo }{1: }|
+ {4:heee }{1: }|
+ {5:-- INSERT --} |
+ ]])
+ end)
end)
diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim
@@ -5059,4 +5059,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