diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index f384afa1ae988d8d224f9ec3de70932543519571..cf9da6cc46529b97c9087ed15c9ae7b9fbda086e 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -3270,6 +3270,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; @@ -10974,7 +10978,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, @@ -11044,7 +11048,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.