diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index cd6cf033db..2407606a66 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -417,6 +417,15 @@ impl TextLayout { let mut line_origin = bounds.origin; let text_style = window.text_style(); for line in &element_state.lines { + line.paint_background( + line_origin, + line_height, + text_style.text_align, + Some(bounds), + window, + cx, + ) + .log_err(); line.paint( line_origin, line_height, diff --git a/crates/gpui/src/text_system/line.rs b/crates/gpui/src/text_system/line.rs index 1ebec668c7..ee351c342a 100644 --- a/crates/gpui/src/text_system/line.rs +++ b/crates/gpui/src/text_system/line.rs @@ -153,6 +153,36 @@ impl WrappedLine { Ok(()) } + + /// Paint the background of line of text to the window. + pub fn paint_background( + &self, + origin: Point, + line_height: Pixels, + align: TextAlign, + bounds: Option>, + window: &mut Window, + cx: &mut App, + ) -> Result<()> { + let align_width = match bounds { + Some(bounds) => Some(bounds.size.width), + None => self.layout.wrap_width, + }; + + paint_line_background( + origin, + &self.layout.unwrapped_layout, + line_height, + align, + align_width, + &self.decoration_runs, + &self.wrap_boundaries, + window, + cx, + )?; + + Ok(()) + } } fn paint_line(