editor: Do not correct text contrast on non-opaque editor (#37471)
Smit Barmase
created
We don’t know the background color behind a non-opaque editor, so we
should skip contrast correction in that case. This prevents
single-editor mode (which is always transparent) from showing weird text
colors when text is selected.
We can’t account for the actual background during contrast correction
because we compute contrast outside gpui, while the actual color
blending happens inside gpui during drawing.
<img width="522" height="145" alt="image"
src="https://github.com/user-attachments/assets/6ee71475-f666-482d-87e6-15cf4c4fceef"
/>
Release Notes:
- Fixed an issue where Command Palette text looked faded when selected.
@@ -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.