From 26cacf15952793ad870e315c4291deee67808b0a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 20 Nov 2021 18:55:34 -0500 Subject: more wrapping bugs --- CHANGELOG.md | 3 +-- src/grid.rs | 1 - src/row.rs | 3 ++- tests/data/fixtures/ich_dch_ech.in | 2 ++ tests/data/fixtures/ich_dch_ech/13.json | 23 +++++++++++++++++++++++ tests/data/fixtures/ich_dch_ech/13.typescript | 1 + tests/data/fixtures/ich_dch_ech/14.json | 20 ++++++++++++++++++++ tests/data/fixtures/ich_dch_ech/14.typescript | 1 + 8 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 tests/data/fixtures/ich_dch_ech/13.json create mode 100644 tests/data/fixtures/ich_dch_ech/13.typescript create mode 100644 tests/data/fixtures/ich_dch_ech/14.json create mode 100644 tests/data/fixtures/ich_dch_ech/14.typescript diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a0b2c6..f277460 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,11 @@ ## Fixed -* Fixed some line wrapping state issues with `contents_diff` +* Fixed various line wrapping state issues * Fixed cursor positioning after writing zero width characters at the end of the line * Fixed `Screen::cursor_state_formatted` to draw the last character in a line with the appropriate drawing attributes if it needs to redraw it -* Maintain wrapped state when overwriting a wide character at the end of a line ## [0.13.0] - 2021-11-17 diff --git a/src/grid.rs b/src/grid.rs index d2eafff..173910a 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -473,7 +473,6 @@ impl Grid { let pos = self.pos; let row = self.current_row_mut(); for col in pos.col..((pos.col + count).min(size.cols)) { - row.clear_wide(col); row.erase(col as usize, attrs); } } diff --git a/src/row.rs b/src/row.rs index 7347568..b15266e 100644 --- a/src/row.rs +++ b/src/row.rs @@ -49,9 +49,10 @@ impl Row { } pub fn erase(&mut self, i: usize, attrs: crate::attrs::Attrs) { + let wide = self.cells.get_mut(i).unwrap().is_wide(); self.clear_wide(i.try_into().unwrap()); self.cells.get_mut(i).unwrap().clear(attrs); - if i == self.cols() as usize - 1 { + if i == self.cols() as usize - if wide { 2 } else { 1 } { self.wrapped = false; } } diff --git a/tests/data/fixtures/ich_dch_ech.in b/tests/data/fixtures/ich_dch_ech.in index 7d3c6f6..ee7ec70 100644 --- a/tests/data/fixtures/ich_dch_ech.in +++ b/tests/data/fixtures/ich_dch_ech.in @@ -10,3 +10,5 @@ obar \x1b[10;11H\x1b[400X \x1b[1;80H \x1b[@ \x1b[1;80H \x1b[X +\x1bc\x1b[1;78Hネab +\x1b[H\x1b[@ diff --git a/tests/data/fixtures/ich_dch_ech/13.json b/tests/data/fixtures/ich_dch_ech/13.json new file mode 100644 index 0000000..3f67407 --- /dev/null +++ b/tests/data/fixtures/ich_dch_ech/13.json @@ -0,0 +1,23 @@ +{ + "contents": " ネab", + "cells": { + "0,77": { + "contents": "ネ", + "is_wide": true + }, + "0,78": { + "contents": "", + "is_wide_continuation": true + }, + "0,79": { + "contents": "a" + }, + "1,0": { + "contents": "b" + } + }, + "cursor_position": [ + 1, + 1 + ] +} \ No newline at end of file diff --git a/tests/data/fixtures/ich_dch_ech/13.typescript b/tests/data/fixtures/ich_dch_ech/13.typescript new file mode 100644 index 0000000..dca42a7 --- /dev/null +++ b/tests/data/fixtures/ich_dch_ech/13.typescript @@ -0,0 +1 @@ +cネab \ No newline at end of file diff --git a/tests/data/fixtures/ich_dch_ech/14.json b/tests/data/fixtures/ich_dch_ech/14.json new file mode 100644 index 0000000..a8f912c --- /dev/null +++ b/tests/data/fixtures/ich_dch_ech/14.json @@ -0,0 +1,20 @@ +{ + "contents": " ネ\nb", + "cells": { + "0,78": { + "contents": "ネ", + "is_wide": true + }, + "0,79": { + "contents": "", + "is_wide_continuation": true + }, + "1,0": { + "contents": "b" + } + }, + "cursor_position": [ + 0, + 0 + ] +} \ No newline at end of file diff --git a/tests/data/fixtures/ich_dch_ech/14.typescript b/tests/data/fixtures/ich_dch_ech/14.typescript new file mode 100644 index 0000000..f6122a6 --- /dev/null +++ b/tests/data/fixtures/ich_dch_ech/14.typescript @@ -0,0 +1 @@ +[@ \ No newline at end of file -- cgit v1.2.3-54-g00ecf