diff --git a/src/text/line.rs b/src/text/line.rs index 15125ddf1f..6a60e4a8b7 100644 --- a/src/text/line.rs +++ b/src/text/line.rs @@ -591,6 +591,7 @@ impl WidgetRef for Line<'_> { if area.is_empty() { return; } + let area = Rect { height: 1, ..area }; let line_width = self.width(); if line_width == 0 { return; @@ -1123,6 +1124,17 @@ mod tests { assert_eq!(buf, expected); } + #[test] + fn render_only_styles_first_line() { + let mut buf = Buffer::empty(Rect::new(0, 0, 20, 2)); + hello_world().render(buf.area, &mut buf); + let mut expected = Buffer::with_lines(["Hello world! ", " "]); + expected.set_style(Rect::new(0, 0, 20, 1), ITALIC); + expected.set_style(Rect::new(0, 0, 6, 1), BLUE); + expected.set_style(Rect::new(6, 0, 6, 1), GREEN); + assert_eq!(buf, expected); + } + #[test] fn render_truncates() { let mut buf = Buffer::empty(Rect::new(0, 0, 10, 1));