]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0837: Using wrong colors in hl_blend_attr() v9.2.0837
authorShad <shadow.walker@free.fr>
Wed, 22 Jul 2026 20:01:09 +0000 (20:01 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 22 Jul 2026 20:01:09 +0000 (20:01 +0000)
Problem:  Using wrong colors in hl_blend_attr()
          (after v9.2.0715)
Solution: Use the correct background color
          (Shad)

related: #20624
closes:  #20704

Signed-off-by: Shad <shadow.walker@free.fr>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/highlight.c
src/testdir/dumps/Test_popup_opacity_lowcolor.dump [new file with mode: 0644]
src/testdir/dumps/Test_popupwin_opacity_hl_80.dump
src/testdir/dumps/Test_pum_opacity_lowcolor.dump [new file with mode: 0644]
src/testdir/test_popup.vim
src/testdir/test_popupwin.vim
src/testdir/util/term_util.vim
src/version.c

index 2e1b343291d011844ac32b9fdaaa8480bcaebde2..1b9cbed7c2861e283c0debca8b7784217535639a 100644 (file)
@@ -3581,7 +3581,7 @@ hl_blend_attr(int char_attr, int popup_attr, int blend, int blend_fg UNUSED)
                    under_fg_rgb = char_aep->ae_u.cterm.fg_rgb;
 #endif
                new_en.ae_u.cterm.fg_color = blend_cterm_colors(
-                       popup_aep->ae_u.cterm.fg_color, popup_bg_rgb,
+                       popup_aep->ae_u.cterm.bg_color, popup_bg_rgb,
                        under_fg, under_fg_rgb, fallback_fg_rgb, blend);
            }
            // Approximate cterm bg by blending with the underlying bg
@@ -3815,7 +3815,7 @@ hl_pum_blend_attr(int char_attr, int popup_attr, int blend UNUSED)
                    under_fg_rgb = char_aep->ae_u.cterm.fg_rgb;
 #endif
                new_en.ae_u.cterm.fg_color = blend_cterm_colors(
-                       popup_aep->ae_u.cterm.fg_color, popup_bg_rgb,
+                       popup_aep->ae_u.cterm.bg_color, popup_bg_rgb,
                        under_fg, under_fg_rgb, fallback_fg_rgb, blend);
            }
            // Approximate cterm bg by blending with the underlying bg
diff --git a/src/testdir/dumps/Test_popup_opacity_lowcolor.dump b/src/testdir/dumps/Test_popup_opacity_lowcolor.dump
new file mode 100644 (file)
index 0000000..530b0cb
--- /dev/null
@@ -0,0 +1,12 @@
+>u+0&#ffffff0|n|d|e|r| |u|n|d|e|r| |u|n|d|e|r| @42
+|u|n|╔+0#0000001#ff40ff14|═@21|╗| +0#0000000#ffffff0@33
+|u|n|║+0#0000001#ff40ff14|e+0#ff40ff14&|r| |u|n|d|e|r| |u|n|d|e|r| @7|║+0#0000001&| +0#0000000#ffffff0@33
+|u|n|║+0#0000001#ff40ff14|e+0#ff40ff14&|P+0#0000001&|o|p|u|p|e+0#ff40ff14&|P+0#0000001&|o|p|u|p|e+0#ff40ff14&|r| @7|║+0#0000001&| +0#0000000#ffffff0@33
+|u|n|║+0#0000001#ff40ff14|e+0#ff40ff14&|r| |u|n|d|e|r| |u|n|d|e|r| @7|║+0#0000001&| +0#0000000#ffffff0@33
+|u|n|║+0#0000001#ff40ff14|e+0#ff40ff14&|r| |u|n|d|e|r| |u|n|d|e|r| @7|║+0#0000001&| +0#0000000#ffffff0@33
+|u|n|╚+0#0000001#ff40ff14|═@21|╝| +0#0000000#ffffff0@33
+|u|n|d|e|r| |u|n|d|e|r| |u|n|d|e|r| @42
+|u|n|d|e|r| |u|n|d|e|r| |u|n|d|e|r| @42
+|u|n|d|e|r| |u|n|d|e|r| |u|n|d|e|r| @42
+|~+0#4040ff13&| @58
+| +0#0000000&@41|1|,|1| @10|A|l@1| 
index 78d311545079b0356bbdabdfc9799b7463e05d14..c57365eaae9c4bde79fb59e2eac77b010ca09f9b 100644 (file)
@@ -1,7 +1,7 @@
 >1+0&#ffffff0| @73
 |2| @73
-|3| @7|f+0#ff404010#87d7ff255|o@1| +0#d75f5f255&@1|b+0#0000001&|a|r| +0#0000000#ffffff0@57
-|4| @7|b+0#0000001#87d7ff255|a|z| +0#0000000&@4| +0&#ffffff0@57
+|3| @7|f+0#ff404010#87d7ff255|o@1| +0#5fafd7255&@1|b+0#0000001&|a|r| +0#0000000#ffffff0@57
+|4| @7|b+0#0000001#87d7ff255|a|z| +0#5fafd7255&@4| +0#0000000#ffffff0@57
 |5| @73
 |6| @73
 |7| @73
diff --git a/src/testdir/dumps/Test_pum_opacity_lowcolor.dump b/src/testdir/dumps/Test_pum_opacity_lowcolor.dump
new file mode 100644 (file)
index 0000000..6c585e0
--- /dev/null
@@ -0,0 +1,12 @@
+|i+0&#ffffff0|t|e|m> @55
+|i+0#0000001#e0e0e08|t|e|m|r+0#e0e0e08&| |u|n|d|e|r| |u|n|d|e+0#0000000#ffffff0|r| @42
+|a+0#0000001#ff40ff14|n|o|t|h|e|r| |i|t|e|m|u+0#ff40ff14&|n|d|e+0#0000000#ffffff0|r| @42
+|a+0#0000001#ff40ff14|n|d| |a| |l|a|s|t| |o|n|e|d+0#ff40ff14&|e+0#0000000#ffffff0|r| @42
+|u|n|d|e|r| |u|n|d|e|r| |u|n|d|e|r| @42
+|u|n|d|e|r| |u|n|d|e|r| |u|n|d|e|r| @42
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|~| @58
+|~| @58
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@29|1|,|5| @10|A|l@1| 
index fd25e93ebec4aa53161c68787c8014665831d593..a4bba3f3103e880642121ac522f645664fcb9460 100644 (file)
@@ -2706,6 +2706,29 @@ func Test_pumopt_opacity_pmenu_cleared()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_pum_opacity_lowcolor()
+  CheckScreendump
+
+  let lines =<< trim END
+  set pumopt=opacity:50
+  call setline(1, '')
+  for i in range(5)
+    call append(line('$'), 'under under under')
+  endfor
+  normal gg
+  inoremap <F5> <Cmd>call complete(col('.'),
+        \ ['item', 'another item', 'and a last one'])<CR>
+  END
+  call writefile(lines, 'XtestPumOpacityLowcolor', 'D')
+  let buf = RunVimInTerminal('-S XtestPumOpacityLowcolor', #{rows: 12, cols: 60, tcolors: 16})
+
+  call term_sendkeys(buf, "i\<F5>")
+  call TermWait(buf, 100)
+  call VerifyScreenDump(buf, 'Test_pum_opacity_lowcolor', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_popup_sandbox()
   call assert_fails('sandbox call popup_create("hello", {})', 'E48:')
   call assert_fails('sandbox call popup_setoptions(1, {})', 'E48:')
index 67babab1b221d3ead25eb2304b9a71bd70841fb4..364a50fe02ccf811858c90fb274f3b16ae96bc54 100644 (file)
@@ -5831,6 +5831,27 @@ func Test_popup_opacity_attr()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_popup_opacity_lowcolor()
+  CheckScreendump
+
+  let lines =<< trim END
+  call setline(1, repeat(['under under under'], 10))
+  call popup_create('Popup Popup', #{
+        \ line: 2, col: 3,
+        \ border: [1, 1, 1, 1],
+        \ padding: [1, 1, 1 ,1],
+        \ minwidth: 20,
+        \ minheight: 2,
+        \ opacity: 70,
+        \ })
+  END
+  call writefile(lines, 'XtestPopupOpacityLowcolor', 'D')
+  let buf = RunVimInTerminal('-S XtestPopupOpacityLowcolor', #{rows: 12, cols: 60, tcolors: 16})
+  call VerifyScreenDump(buf, 'Test_popup_opacity_lowcolor', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_popup_image_update()
   CheckFeature image
 
index 61ff9ce1b89e6eddf096825ff169bbb26ccb7457..afb44c8dbb8ecdcdf62d29206c009ebaa1da4baf 100644 (file)
@@ -58,6 +58,7 @@ endfunc
 " "no_clean" - if non-zero then remove "--clean" from the command
 " "cmd"  - run any other command, e.g. "xxd" (used in xxd test)
 " "env"  - additional environment variables, e.g. $TERM variable
+" "tcolor"  - terminal color number (256 by default)
 func RunVimInTerminal(arguments, options)
   " If Vim doesn't exit a swap file remains, causing other tests to fail.
   " Remove it here.
@@ -76,8 +77,11 @@ func RunVimInTerminal(arguments, options)
   split
   vsplit
 
-  " Always do this with 256 colors and a light background.
-  set t_Co=256 background=light
+  " Always do this with light background.
+  set background=light
+  " and 256 colors by default
+  let tcolors = get(a:options, 'tcolors', 256)
+  let &t_Co=tcolors
   hi Normal ctermfg=NONE ctermbg=NONE
 
   " Make the window 20 lines high and 75 columns, unless told otherwise or
index d81425099475eca66671b593718028f18213926e..d463a17d81673d8d3cad83479cd98b065e998b7f 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    837,
 /**/
     836,
 /**/