From: Hirohito Higashi Date: Wed, 22 Jul 2026 10:03:11 +0000 (+0000) Subject: patch 9.2.0830: the completion menu is not used on terminals without colors X-Git-Tag: v9.2.0830^0 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=52485e0d24ade45e02ecba9aeadaec66500d15fe;p=thirdparty%2Fvim.git patch 9.2.0830: the completion menu is not used on terminals without colors Problem: When the terminal reports no colors ("t_Co" is 0 or 1) the insert mode completion popup menu is not shown at all, while the command line completion popup menu ('wildoptions' contains "pum") is shown. In 'wildmenu' completion the current match cannot be told apart from the other matches (Maxim Kim) Solution: Show the insert mode completion popup menu regardless of the number of colors and add "term" attributes to the default highlighting of Pmenu, PmenuSel and PmenuThumb. The wildmenu is drawn with the attributes of the status line, which is reversed, and on most terminals the standout mode is the same as the reverse mode, thus use the underline mode for the default highlighting of WildMenu (Hirohito Higashi). fixes: #20800 closes: #20803 Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 688d65fb3f..f581d50cf8 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 9.2. Last change: 2026 Jun 13 +*insert.txt* For Vim version 9.2. Last change: 2026 Jul 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1389,7 +1389,6 @@ Vim can display the matches in a simplistic popup menu. The menu is used when: - The 'completeopt' option contains "menu" or "menuone". -- The terminal supports at least 8 colors. - There are at least two matches. One if "menuone" is used. The 'pumheight' option can be used to set a maximum height. The default is to diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 549b22a853..15e26e4484 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2302,8 +2302,8 @@ A jump table for the options with a short description can be found at |Q_op|. See also |preinserted()|. menu Use a popup menu to show the possible completions. The - menu is only shown when there is more than one match and - sufficient colors are available. |ins-completion-menu| + menu is only shown when there is more than one match. + |ins-completion-menu| menuone Use the popup menu also when there is only one match. Useful when there is additional information about the diff --git a/src/highlight.c b/src/highlight.c index efe21455f2..5925ead6b0 100644 --- a/src/highlight.c +++ b/src/highlight.c @@ -283,8 +283,8 @@ static char *(highlight_init_both[]) = { "DiffText term=reverse cterm=bold ctermbg=Red gui=bold guibg=Red"), "default link DiffTextAdd DiffText", #endif - CENT("PmenuSbar ctermbg=Grey", - "PmenuSbar ctermbg=Grey guibg=Grey"), + CENT("PmenuSbar term=NONE ctermbg=Grey", + "PmenuSbar term=NONE ctermbg=Grey guibg=Grey"), CENT("TabLineSel term=bold cterm=bold", "TabLineSel term=bold cterm=bold gui=bold"), CENT("TabLineFill term=reverse cterm=reverse", @@ -346,22 +346,22 @@ static char *(highlight_init_light[]) = { CENT("SpellLocal term=underline ctermbg=Cyan", "SpellLocal term=underline ctermbg=Cyan guisp=DarkCyan gui=undercurl"), #endif - CENT("PmenuThumb ctermbg=Black", - "PmenuThumb ctermbg=Black guibg=Black"), - CENT("PmenuShadow ctermbg=Black ctermfg=DarkGrey", - "PmenuShadow ctermbg=Black ctermfg=DarkGrey guibg=Black guifg=DarkGrey"), - CENT("Pmenu ctermbg=LightMagenta ctermfg=Black", - "Pmenu ctermbg=LightMagenta ctermfg=Black guibg=LightMagenta"), - CENT("PmenuSel ctermbg=LightGrey ctermfg=Black", - "PmenuSel ctermbg=LightGrey ctermfg=Black guibg=Grey"), + CENT("PmenuThumb term=reverse ctermbg=Black", + "PmenuThumb term=reverse ctermbg=Black guibg=Black"), + CENT("PmenuShadow term=NONE ctermbg=Black ctermfg=DarkGrey", + "PmenuShadow term=NONE ctermbg=Black ctermfg=DarkGrey guibg=Black guifg=DarkGrey"), + CENT("Pmenu term=reverse ctermbg=LightMagenta ctermfg=Black", + "Pmenu term=reverse ctermbg=LightMagenta ctermfg=Black guibg=LightMagenta"), + CENT("PmenuSel term=underline ctermbg=LightGrey ctermfg=Black", + "PmenuSel term=underline ctermbg=LightGrey ctermfg=Black guibg=Grey"), CENT("SpecialKey term=NONE ctermfg=DarkBlue", "SpecialKey term=NONE ctermfg=DarkBlue guifg=Blue"), CENT("Title term=bold ctermfg=DarkMagenta", "Title term=bold ctermfg=DarkMagenta gui=bold guifg=Magenta"), CENT("WarningMsg term=standout ctermfg=DarkRed", "WarningMsg term=standout ctermfg=DarkRed guifg=Red"), - CENT("WildMenu term=standout ctermbg=Yellow ctermfg=Black", - "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"), + CENT("WildMenu term=underline ctermbg=Yellow ctermfg=Black", + "WildMenu term=underline ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"), #ifdef FEAT_FOLDING CENT("Folded term=standout ctermbg=Grey ctermfg=DarkBlue", "Folded term=standout ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue"), @@ -439,20 +439,20 @@ static char *(highlight_init_dark[]) = { CENT("SpellLocal term=underline ctermbg=Cyan", "SpellLocal term=underline ctermbg=Cyan guisp=Cyan gui=undercurl"), #endif - CENT("PmenuThumb ctermbg=White", - "PmenuThumb ctermbg=White guibg=White"), - CENT("PmenuShadow ctermbg=Black ctermfg=DarkGrey", - "PmenuShadow ctermbg=Black ctermfg=DarkGrey guibg=Black guifg=DarkGrey"), - CENT("Pmenu ctermbg=Magenta ctermfg=Black", - "Pmenu ctermbg=Magenta ctermfg=Black guibg=Magenta"), - CENT("PmenuSel ctermbg=Black ctermfg=DarkGrey", - "PmenuSel ctermbg=Black ctermfg=DarkGrey guibg=DarkGrey"), + CENT("PmenuThumb term=reverse ctermbg=White", + "PmenuThumb term=reverse ctermbg=White guibg=White"), + CENT("PmenuShadow term=NONE ctermbg=Black ctermfg=DarkGrey", + "PmenuShadow term=NONE ctermbg=Black ctermfg=DarkGrey guibg=Black guifg=DarkGrey"), + CENT("Pmenu term=reverse ctermbg=Magenta ctermfg=Black", + "Pmenu term=reverse ctermbg=Magenta ctermfg=Black guibg=Magenta"), + CENT("PmenuSel term=underline ctermbg=Black ctermfg=DarkGrey", + "PmenuSel term=underline ctermbg=Black ctermfg=DarkGrey guibg=DarkGrey"), CENT("Title term=bold ctermfg=LightMagenta", "Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta"), CENT("WarningMsg term=standout ctermfg=LightRed", "WarningMsg term=standout ctermfg=LightRed guifg=Red"), - CENT("WildMenu term=standout ctermbg=Yellow ctermfg=Black", - "WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"), + CENT("WildMenu term=underline ctermbg=Yellow ctermfg=Black", + "WildMenu term=underline ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black"), #ifdef FEAT_FOLDING CENT("Folded term=standout ctermbg=DarkGrey ctermfg=Cyan", "Folded term=standout ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan"), diff --git a/src/insexpand.c b/src/insexpand.c index 0833340c70..16b2e7b52b 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -1364,17 +1364,7 @@ ins_compl_del_pum(void) pum_wanted(void) { // 'completeopt' must contain "menu" or "menuone" - if ((get_cot_flags() & COT_ANY_MENU) == 0 && !compl_autocomplete) - return FALSE; - - // The display looks bad on a B&W display. - if (t_colors < 8 -#ifdef FEAT_GUI - && !gui.in_use -#endif - ) - return FALSE; - return TRUE; + return (get_cot_flags() & COT_ANY_MENU) != 0 || compl_autocomplete; } /* diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim index e5d9094f78..fd25e93ebe 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -1286,6 +1286,24 @@ func Test_pum_getpos() unlet g:pum_pos endfunc +" The popup menu is also used on a terminal without colors (issue #20800) +func Test_pum_without_colors() + CheckNotGui + + new + let save_t_Co = &t_Co + set t_Co=0 + inoremap =GetPumPosition() + call setline(1, ['hello', 'help', '']) + call cursor(3, 1) + call feedkeys("ih\\\", 'tx') + call assert_equal(2, g:pum_pos.size) + + let &t_Co = save_t_Co + bw! + unlet g:pum_pos +endfunc + " Test for the popup menu with the 'rightleft' option set func Test_pum_rightleft() CheckFeature rightleft diff --git a/src/version.c b/src/version.c index 7efb39e2a5..77223f6664 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 830, /**/ 829, /**/