From b865db455db19e192746980aee0e2c32c286afc7 Mon Sep 17 00:00:00 2001 From: Robert Clover Date: Tue, 30 Jan 2024 16:01:02 +1100 Subject: [PATCH] Fix terminal line background being reset on each line (#7040) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Release Notes: - Fixed #5027 - Fixed #5079 Info: The terminal draws a rectangle for the background color of cells, but this was being reset on every line. The effect of this was that tools like Vim, Helix, and git-delta would only have one line with a background color: Screenshot 2024-01-30 at 2 48 13 pm After this change: Screenshot 2024-01-30 at 2 49 45 pm --- crates/terminal_view/src/terminal_element.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index aebfdd28c2e02508c7e0235add3d818489876295..c691d74754ddb4d83473d6de6d01ce911d427638 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -218,7 +218,22 @@ impl TerminalElement { match cur_alac_color { Some(cur_color) => { if bg == cur_color { - cur_rect = cur_rect.take().map(|rect| rect.extend()); + // `cur_rect` can be None if it was moved to the `rects` vec after wrapping around + // from one line to the next. The variables are all set correctly but there is no current + // rect, so we create one if necessary. + cur_rect = cur_rect.map_or_else( + || { + Some(LayoutRect::new( + AlacPoint::new( + line_index as i32, + cell.point.column.0 as i32, + ), + 1, + convert_color(&bg, theme), + )) + }, + |rect| Some(rect.extend()), + ); } else { cur_alac_color = Some(bg); if cur_rect.is_some() {