aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-29 13:19:43 -0500
committerJesse Luehrs <doy@tozt.net>2019-12-05 12:54:34 -0500
commitb815e4dabbc3d8bb61c569126c54f18e20bce6ec (patch)
tree46dc10e75f2c215ee1060d2fd9480d1703ab8ea2
parenta0cbd79c92f9a4703f254291d7fbffaa2c84ffb0 (diff)
downloadvt100-rust-b815e4dabbc3d8bb61c569126c54f18e20bce6ec.tar.gz
vt100-rust-b815e4dabbc3d8bb61c569126c54f18e20bce6ec.zip
simplify the behavior around end of line wrapping here
the behavior i was aiming for had way too many special cases, so just stop trying to do it and do the simple thing instead (this is all stuff that is essentially never going to come up in reality).
-rw-r--r--src/screen.rs23
-rw-r--r--tests/text.rs4
2 files changed, 9 insertions, 18 deletions
diff --git a/src/screen.rs b/src/screen.rs
index f8844aa..8bb8b0e 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -636,9 +636,13 @@ impl Screen {
let wrap_width = if width == 0 { 1 } else { width };
// it doesn't make any sense to wrap if the last column in a row
- // didn't already have contents (but if a wide character wraps because
- // there was only one column left in the previous row, that should
- // still count)
+ // didn't already have contents. don't try to handle the case where a
+ // character wraps because there was only one column left in the
+ // previous row - literally everything handles this case differently,
+ // and this is tmux behavior (and also the simplest). i'm open to
+ // reconsidering this behavior, but only with a really good reason
+ // (xterm handles this by introducing the concept of triple width
+ // cells, which i really don't want to do).
let mut wrap = false;
if pos.col > size.cols - wrap_width {
let last_cell = self
@@ -650,19 +654,6 @@ impl Screen {
if last_cell.has_contents() || last_cell.is_wide_continuation() {
wrap = true;
}
- if wrap_width > 1 {
- let last_last_cell = self
- .drawing_cell(crate::grid::Pos {
- row: pos.row,
- col: size.cols - 2,
- })
- .unwrap();
- if last_last_cell.has_contents()
- || last_last_cell.is_wide_continuation()
- {
- wrap = true;
- }
- }
}
self.grid_mut().col_wrap(wrap_width, wrap);
diff --git a/tests/text.rs b/tests/text.rs
index 74001d1..087755a 100644
--- a/tests/text.rs
+++ b/tests/text.rs
@@ -219,10 +219,10 @@ fn wrap() {
assert_eq!(parser.screen().contents(), "0123456789012345678901234567890123456789012345678901234567890123456789012345678");
assert_eq!(parser.screen().cursor_position(), (0, 79));
parser.process("ネ".as_bytes());
- assert_eq!(parser.screen().contents(), "0123456789012345678901234567890123456789012345678901234567890123456789012345678ネ");
+ assert_eq!(parser.screen().contents(), "0123456789012345678901234567890123456789012345678901234567890123456789012345678\nネ");
assert_eq!(parser.screen().cursor_position(), (1, 2));
parser.process(b"a");
- assert_eq!(parser.screen().contents(), "0123456789012345678901234567890123456789012345678901234567890123456789012345678ネa");
+ assert_eq!(parser.screen().contents(), "0123456789012345678901234567890123456789012345678901234567890123456789012345678\nネa");
assert_eq!(parser.screen().cursor_position(), (1, 3));
assert_eq!(parser.screen().cell(0, 77).unwrap().contents(), "7");
assert_eq!(parser.screen().cell(0, 78).unwrap().contents(), "8");