neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 5803994a1c4aa6c9b403a246644437f11c8a1e45
parent e644038f06b4e3401f9b496bbe4337bfe8b18146
Author: glepnir <glephunter@gmail.com>
Date:   Thu, 10 Jul 2025 20:42:45 +0800

fix(highlight): preserve bg transparency with winblend=100 #34825

Problem: When winblend=100 is set on floating windows with transparent
background, the desktop background is not visible through the window.

Solution: Add special case to preserve transparency (-1) when blend
ratio is 100% and background was originally transparent.
Diffstat:
Msrc/nvim/highlight.c | 14++++++++++----
Mtest/functional/ui/float_spec.lua | 5+++--
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c @@ -754,10 +754,16 @@ int hl_blend_attrs(int back_attr, int front_attr, bool *through) } // Check if we should preserve background transparency - // Use the raw attributes (before forcing colors) to check original transparency - cattrs.rgb_bg_color = (battrs_raw.rgb_bg_color == -1) && (fattrs_raw.rgb_bg_color == -1) - ? -1 - : rgb_blend(ratio, battrs.rgb_bg_color, fattrs.rgb_bg_color); + // Special case for blend=100: preserve back layer background exactly (including bg=NONE) + if (ratio == 100 && battrs_raw.rgb_bg_color == -1) { + // For 100% blend with transparent background, preserve the transparency + cattrs.rgb_bg_color = -1; + } else { + // Use the raw attributes (before forcing colors) to check original transparency + cattrs.rgb_bg_color = (battrs_raw.rgb_bg_color == -1) && (fattrs_raw.rgb_bg_color == -1) + ? -1 + : rgb_blend(ratio, battrs.rgb_bg_color, fattrs.rgb_bg_color); + } cattrs.hl_blend = -1; // blend property was consumed HlKind kind = *through ? kHlBlendThrough : kHlBlend; id = get_attr_entry((HlEntry){ .attr = cattrs, .kind = kind, diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua @@ -959,6 +959,7 @@ describe('float window', function() [28] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, [29] = { background = Screen.colors.Yellow1, foreground = Screen.colors.Blue4 }, [30] = { background = Screen.colors.Grey, foreground = Screen.colors.Blue4, bold = true }, + [31] = { foreground = Screen.colors.Grey0 }, } screen:set_default_attr_ids(attrs) end) @@ -1839,9 +1840,9 @@ describe('float window', function() grid = [[ neeed some dummy | background text | - to sh{1: halloj! }{23:f}ect | + to sh{1: halloj! }{31:f}ect | of co{1: BORDAA }{24:i}ng | - of bo{23:r}{24:der shado}w | + of bo{31:r}{24:der shado}w | ^ | | ]],