From dbacf98b89ca839fa5c930597327392b33d7de0e Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 6 Sep 2022 20:01:30 -0700 Subject: [PATCH] fix incorrect underline attribute when scrolling Given this sequence: ENABLE-UNDERLINE CRLF SGR-RESET if the CRLF caused the terminal to scroll, the newly created line at the bottom would be filled in with a "blank" cell that had the underline attribute set. That's because we're supposed to preserve the coloring in that scenario, but we were also preserving other SGR attributes. This commit explicitly clears out under, over and strikethrough lines from these blank attributes. refs: https://github.com/wez/wezterm/issues/2489 --- docs/changelog.md | 3 +++ termwiz/src/cell.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 4362d18c5..e44624280 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -16,6 +16,9 @@ As features stabilize some brief notes about them will accumulate here. Thanks to [@unrelentingtech](https://github.com/unrelentingtech)! [#2492](https://github.com/wez/wezterm/pull/2492) [#2452](https://github.com/wez/wezterm/issues/2452) +* If the underline attribute was active and CRLF scrolled a new line into the + bottom of the display, we'd fill that new line with underlines. + [#2489](https://github.com/wez/wezterm/issues/2489) ### 20220905-102802-7d4b8249 diff --git a/termwiz/src/cell.rs b/termwiz/src/cell.rs index b4cb1d7b0..e69da2bd5 100644 --- a/termwiz/src/cell.rs +++ b/termwiz/src/cell.rs @@ -483,6 +483,20 @@ impl CellAttributes { // easier time in get_semantic_zones. res.set_semantic_type(SemanticType::default()); res.set_underline_color(self.underline_color()); + + // Turn off underline because it can have surprising results + // if underline is on, then we get CRLF and then SGR reset: + // If the CRLF causes a line to scroll, we'll call clone_sgr_only() + // to get a blank cell for the new line and it would be filled + // with underlines. + // clone_sgr_only() is primarily for preserving the background + // color when erasing rather than other attributes, so it should + // be fine to clear out the actual underline attribute. + // Let's extend this to other line attribute types as well. + // + res.set_underline(Underline::None); + res.set_overline(false); + res.set_strikethrough(false); res }