diff options
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/cell.rs | 4 | ||||
-rw-r--r-- | tests/text.rs | 6 |
3 files changed, 13 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 969385a..bc2c52f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ * Fix a couple more end-of-line/wrapping bugs. * Fix applying combining characters to wide characters. +* Ensure cells can't have contents with width zero (to avoid ambiguity). If an + empty cell gets a combining character applied to it, default that cell to a + (normal-width) space first. ## [0.7.0] - 2019-11-23 diff --git a/src/cell.rs b/src/cell.rs index 5da4452..f9f9056 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -44,6 +44,10 @@ impl Cell { if self.len() >= CODEPOINTS_IN_CELL { return; } + if self.len() == 0 { + self.contents[self.len()] = ' '; + self.len += 1; + } self.contents[self.len()] = c; self.len += 1; diff --git a/tests/text.rs b/tests/text.rs index d153f11..74001d1 100644 --- a/tests/text.rs +++ b/tests/text.rs @@ -167,6 +167,12 @@ fn combining() { parser.process("\x1b[H\x1b[Ja\u{0301}".as_bytes()); assert_eq!(parser.screen().cell(0, 0).unwrap().contents(), "a\u{0301}"); assert_eq!(parser.screen().cell(0, 1).unwrap().contents(), ""); + + parser.process("\x1b[H\x1b[J\x1b[2C\u{0301}".as_bytes()); + assert_eq!(parser.screen().cell(0, 0).unwrap().contents(), ""); + assert_eq!(parser.screen().cell(0, 1).unwrap().contents(), " \u{0301}"); + assert_eq!(parser.screen().cell(0, 2).unwrap().contents(), ""); + assert_eq!(parser.screen().cell(0, 3).unwrap().contents(), ""); } #[test] |