Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix blend alpha colors with editor background in inline preview (#33513)

ddoemonn338a7395a7af
diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs
index fd371e20cbf..a10a5f074c1 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);
}
}