From c5c02112a61221f231fdd8c6cd9bbaa604474d9d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 13 Nov 2019 12:58:55 -0500 Subject: fix zero width characters at the end of a row --- CHANGELOG.md | 6 ++++++ src/screen.rs | 2 +- tests/text.rs | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 610f008..a5c5329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixed + +* Fix zero-width characters when the cursor is at the end of a row. + ## [0.6.1] - 2019-11-13 ### Added diff --git a/src/screen.rs b/src/screen.rs index c563f37..f28fb90 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -592,7 +592,6 @@ impl Screen { let attrs = self.attrs; self.grid_mut().col_wrap(width); - let cell = self.current_cell_mut(); if width == 0 { if pos.col > 0 { @@ -621,6 +620,7 @@ impl Screen { } } } else { + let cell = self.current_cell_mut(); cell.set(c, attrs); self.grid_mut().col_inc(1); if width > 1 { diff --git a/tests/text.rs b/tests/text.rs index e0b4cee..cf90b89 100644 --- a/tests/text.rs +++ b/tests/text.rs @@ -154,6 +154,14 @@ fn combining() { let screen = parser.screen().clone(); parser.process(b"\x1bcabcdefg"); assert_eq!(parser.screen().contents_diff(&screen), b""); + + parser.process(b"\x1bcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + assert_eq!(parser.screen().cursor_position(), (0, 80)); + assert_eq!(parser.screen().contents(), "a".repeat(80)); + + parser.process("\u{0301}".as_bytes()); + assert_eq!(parser.screen().cursor_position(), (0, 80)); + assert_eq!(parser.screen().contents(), format!("{}รก", "a".repeat(79))); } #[test] -- cgit v1.2.3-54-g00ecf