aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-03 14:13:46 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-03 14:13:46 -0500
commit91e0dcd8f9de84a9cd0a45b1e776f59ea527881e (patch)
tree3101f7decc491233fa980625b2de7cd65f6d7031
parent732589c4f0a5dbecc33f8ec4f7626a1cc93a03a8 (diff)
downloadvt100-rust-91e0dcd8f9de84a9cd0a45b1e776f59ea527881e.tar.gz
vt100-rust-91e0dcd8f9de84a9cd0a45b1e776f59ea527881e.zip
fix wrapping while scrolling inside the scroll region too
-rw-r--r--src/grid.rs9
-rw-r--r--tests/data/fixtures/wrap.in1
-rw-r--r--tests/data/fixtures/wrap/32.json15
-rw-r--r--tests/data/fixtures/wrap/32.typescript1
4 files changed, 22 insertions, 4 deletions
diff --git a/src/grid.rs b/src/grid.rs
index 785b3cb..d568205 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -612,13 +612,14 @@ impl Grid {
pub fn col_wrap(&mut self, width: u16, wrap: bool) {
if self.pos.col > self.size.cols - width {
- let prev_pos = self.pos;
+ let mut prev_pos = self.pos;
self.pos.col = 0;
let scrolled = self.row_inc_scroll(1);
+ prev_pos.row -= scrolled;
let new_pos = self.pos;
- self.drawing_row_mut(prev_pos).unwrap().wrap(
- wrap && (prev_pos.row + 1 == new_pos.row || scrolled == 1),
- );
+ self.drawing_row_mut(prev_pos)
+ .unwrap()
+ .wrap(wrap && prev_pos.row + 1 == new_pos.row);
}
}
diff --git a/tests/data/fixtures/wrap.in b/tests/data/fixtures/wrap.in
index e351293..b04ac81 100644
--- a/tests/data/fixtures/wrap.in
+++ b/tests/data/fixtures/wrap.in
@@ -29,3 +29,4 @@ a
\x1bc\na\x1b[1;79Hデ\n
\x1bc\x1b[1;79Hネa\x1b[1;79Hb
\x1bc\x1b[1;79Hネa\x1b[1;78Hネ
+\x1bc\x1b[24;80Hab
diff --git a/tests/data/fixtures/wrap/32.json b/tests/data/fixtures/wrap/32.json
new file mode 100644
index 0000000..cdfc959
--- /dev/null
+++ b/tests/data/fixtures/wrap/32.json
@@ -0,0 +1,15 @@
+{
+ "contents": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ab",
+ "cells": {
+ "22,79": {
+ "contents": "a"
+ },
+ "23,0": {
+ "contents": "b"
+ }
+ },
+ "cursor_position": [
+ 23,
+ 1
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/wrap/32.typescript b/tests/data/fixtures/wrap/32.typescript
new file mode 100644
index 0000000..c15369f
--- /dev/null
+++ b/tests/data/fixtures/wrap/32.typescript
@@ -0,0 +1 @@
+cab \ No newline at end of file