]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0830: the completion menu is not used on terminals without colors v9.2.0830
authorHirohito Higashi <h.east.727@gmail.com>
Wed, 22 Jul 2026 10:03:11 +0000 (10:03 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 22 Jul 2026 10:03:11 +0000 (10:03 +0000)
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) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/insert.txt
runtime/doc/options.txt
src/highlight.c
src/insexpand.c
src/testdir/test_popup.vim
src/version.c

index 688d65fb3f08b1097e07357deffeb8a04a639b44..f581d50cf87ee2c21708142fb7bc1575b401c924 100644 (file)
@@ -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
index 549b22a8533d5973e38261c5f9c3c89f196e88b8..15e26e4484f9071227c9a28cef29eb2b86ca0579 100644 (file)
@@ -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
index efe21455f28df64b187994dadadf888de81171ab..5925ead6b0c4f34ea22f98e7b52133b98ee21960 100644 (file)
@@ -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"),
index 0833340c70a5fcc33f3e52be5f4bf265461410af..16b2e7b52b6c96d52db09087882405b2485dd9fc 100644 (file)
@@ -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;
 }
 
 /*
index e5d9094f78c9d262bacbbf3a4aca321126b48f2c..fd25e93ebec4aa53161c68787c8014665831d593 100644 (file)
@@ -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 <buffer><F5> <C-R>=GetPumPosition()<CR>
+  call setline(1, ['hello', 'help', ''])
+  call cursor(3, 1)
+  call feedkeys("ih\<C-N>\<F5>\<Esc>", '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
index 7efb39e2a58c75e94a6294848c5f793ba6a25f98..77223f6664a8d744a00e4530e90d9d0d06071e53 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    830,
 /**/
     829,
 /**/