From 338a7395a7af38ae4d88623e039d90371196175a Mon Sep 17 00:00:00 2001 From: ddoemonn <109994179+ddoemonn@users.noreply.github.com> Date: Fri, 27 Jun 2025 12:37:05 +0300 Subject: [PATCH] Fix blend alpha colors with editor background in inline preview (#33513) Closes #33505 ## Before Screenshot 2025-06-27 at 12 22 57 ## After Screenshot 2025-06-27 at 12 22 47 Release Notes: - Fixed inline color previews not correctly blending alpha/transparency values with the editor background --- crates/editor/src/display_map.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index fd371e20cbf22585d1dd2640f01104dd16428750..a10a5f074c1c1922f6cdb053e7a4b37dd2230312 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -966,10 +966,22 @@ impl DisplaySnapshot { .and_then(|id| id.style(&editor_style.syntax)); if let Some(chunk_highlight) = chunk.highlight_style { + // For color inlays, blend the color with the editor background + let mut processed_highlight = chunk_highlight; + if chunk.is_inlay { + if let Some(inlay_color) = chunk_highlight.color { + // Only blend if the color has transparency (alpha < 1.0) + if inlay_color.a < 1.0 { + let blended_color = editor_style.background.blend(inlay_color); + processed_highlight.color = Some(blended_color); + } + } + } + if let Some(highlight_style) = highlight_style.as_mut() { - highlight_style.highlight(chunk_highlight); + highlight_style.highlight(processed_highlight); } else { - highlight_style = Some(chunk_highlight); + highlight_style = Some(processed_highlight); } }