diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index fd5e544725696c63af2458447c66813f12f4cba3..c21d31aa5c14e3b596a6089630b29a3e55a3084d 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -3284,6 +3284,10 @@ impl EditorElement { if rows.start >= rows.end { return Vec::new(); } + if !base_background.is_opaque() { + // We don't actually know what color is behind this editor. + return Vec::new(); + } let highlight_iter = highlight_ranges.iter().cloned(); let selection_iter = selections.iter().flat_map(|(player_color, layouts)| { let color = player_color.selection; @@ -11005,7 +11009,7 @@ mod tests { #[gpui::test] fn test_merge_overlapping_ranges() { - let base_bg = Hsla::default(); + let base_bg = Hsla::white(); let color1 = Hsla { h: 0.0, s: 0.5, @@ -11075,7 +11079,7 @@ mod tests { #[gpui::test] fn test_bg_segments_per_row() { - let base_bg = Hsla::default(); + let base_bg = Hsla::white(); // Case A: selection spans three display rows: row 1 [5, end), full row 2, row 3 [0, 7) { diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs index cb7329c03fbb2064da0ef5873eef92c2c33d4953..93c69744a6f9f3cc74e7696e9edf49001587376b 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -473,6 +473,11 @@ impl Hsla { self.a == 0.0 } + /// Returns true if the HSLA color is fully opaque, false otherwise. + pub fn is_opaque(&self) -> bool { + self.a == 1.0 + } + /// Blends `other` on top of `self` based on `other`'s alpha value. The resulting color is a combination of `self`'s and `other`'s colors. /// /// If `other`'s alpha value is 1.0 or greater, `other` color is fully opaque, thus `other` is returned as the output color.