Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix bug where all editor completions would be black (#28548)
Mikayla Makic0262cf62f6d
diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rsindex c264e3c6b7b..faacbc75527 100644--- a/crates/gpui/src/elements/text.rs+++ b/crates/gpui/src/elements/text.rs@@ -1,10 +1,12 @@use crate::{ActiveTooltip, AnyView, App, Bounds, DispatchPhase, Element, ElementId, GlobalElementId,HighlightStyle, Hitbox, IntoElement, LayoutId, MouseDownEvent, MouseMoveEvent, MouseUpEvent,- Pixels, Point, SharedString, Size, TextOverflow, TextRun, TextStyle, TooltipId, WhiteSpace,- Window, WrappedLine, WrappedLineLayout, register_tooltip_mouse_handlers, set_tooltip_on_window,+ Pixels, Point, SharedString, Size, TextAlign, TextOverflow, TextRun, TextStyle,+ TextStyleRefinement, TooltipId, WhiteSpace, Window, WrappedLine, WrappedLineLayout,+ register_tooltip_mouse_handlers, set_tooltip_on_window,};use anyhow::anyhow;+use refineable::Refineable as _;use smallvec::SmallVec;use std::{cell::{Cell, RefCell},@@ -416,13 +418,17 @@ impl TextLayout {let line_height = element_state.line_height;let mut line_origin = bounds.origin;- let text_style = window.text_style();+ // Get current text_style refinements+ let mut text_style = TextStyleRefinement::default();+ for style in window.text_style_stack.iter().as_ref() {+ text_style.refine(&style);+ }for line in &element_state.lines {line.paint_background(line_origin,line_height,- text_style.text_align,+ text_style.text_align.unwrap_or(TextAlign::Left),Some(bounds),window,cx,diff --git a/crates/gpui/src/text_system/line.rs b/crates/gpui/src/text_system/line.rsindex f7553abcea3..35037b261c3 100644--- a/crates/gpui/src/text_system/line.rs+++ b/crates/gpui/src/text_system/line.rs@@ -1,7 +1,7 @@use crate::{App, Bounds, Half, Hsla, LineLayout, Pixels, Point, Result, SharedString, StrikethroughStyle,- TextAlign, TextStyle, UnderlineStyle, Window, WrapBoundary, WrappedLineLayout, black, fill,- point, px, size,+ TextAlign, TextStyleRefinement, UnderlineStyle, Window, WrapBoundary, WrappedLineLayout, black,+ fill, point, px, size,};use derive_more::{Deref, DerefMut};use smallvec::SmallVec;@@ -130,7 +130,7 @@ impl WrappedLine {&self,origin: Point<Pixels>,line_height: Pixels,- text_style: Option<&TextStyle>,+ text_style: Option<&TextStyleRefinement>,bounds: Option<Bounds<Pixels>>,window: &mut Window,cx: &mut App,@@ -190,7 +190,7 @@ fn paint_line(origin: Point<Pixels>,layout: &LineLayout,line_height: Pixels,- text_style: Option<&TextStyle>,+ text_style: Option<&TextStyleRefinement>,align_width: Option<Pixels>,decoration_runs: &[DecorationRun],wrap_boundaries: &[WrapBoundary],@@ -206,7 +206,9 @@ fn paint_line();// TODO: text_align and line_height need to inherit from normal style when is hovered or activated.- let mut text_align = text_style.map(|s| s.text_align).unwrap_or(TextAlign::Left);+ let mut text_align = text_style+ .and_then(|s| s.text_align)+ .unwrap_or(TextAlign::Left);window.paint_layer(line_bounds, |window| {let padding_top = (line_height - layout.ascent - layout.descent) / 2.;@@ -301,7 +303,7 @@ fn paint_line(let mut run_underline = style_run.underline.as_ref();let mut run_strikethrough = style_run.strikethrough;// Override by text run by current style when hovered or activated.- if let Some(val) = text_style.map(|s| s.color) {+ if let Some(val) = text_style.and_then(|s| s.color) {run_color = val;}if let Some(val) = text_style.and_then(|s| s.underline.as_ref()) {