aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/screen.rs15
-rw-r--r--tests/data/fixtures/combining/11.json4
-rw-r--r--tests/data/fixtures/ri.in3
-rw-r--r--tests/data/fixtures/ri/4.json8
-rw-r--r--tests/data/fixtures/ri/4.typescript1
-rw-r--r--tests/data/fixtures/ri/5.json15
-rw-r--r--tests/data/fixtures/ri/5.typescript1
-rw-r--r--tests/data/fixtures/ri/6.json15
-rw-r--r--tests/data/fixtures/ri/6.typescript1
10 files changed, 50 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 123fd37..c863506 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@
## Fixed
* Fixed some line wrapping state issues with `contents_diff`
+* Fixed cursor positioning after writing zero width characters at the end of
+ the line
## [0.13.0] - 2021-11-17
diff --git a/src/screen.rs b/src/screen.rs
index e3581b9..56bd963 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -807,17 +807,6 @@ impl Screen {
let width = c.width().unwrap_or(0).try_into().unwrap();
- // zero width characters still cause the cursor to wrap - this doesn't
- // affect which cell they go into (the "previous cell" for both (row,
- // max_col + 1) and (row + 1, 0) is (row, max_col)), but does affect
- // further movement afterwards - writing an `a` at (row, max_col)
- // followed by a crlf puts the cursor at (row + 1,
- // 0), but writing a `à` (specifically `a` followed by a combining
- // grave accent - the normalized U+00E0 "latin small letter a with
- // grave" behaves the same as `a`) at (row, max_col) followed by a
- // crlf puts the cursor at (row + 2, 0)
- 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. don't try to handle the case where a
// character wraps because there was only one column left in the
@@ -827,7 +816,7 @@ impl Screen {
// (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 {
+ if pos.col > size.cols - width {
let last_cell = self
.drawing_cell(crate::grid::Pos {
row: pos.row,
@@ -838,7 +827,7 @@ impl Screen {
wrap = true;
}
}
- self.grid_mut().col_wrap(wrap_width, wrap);
+ self.grid_mut().col_wrap(width, wrap);
let pos = self.grid().pos();
if width == 0 {
diff --git a/tests/data/fixtures/combining/11.json b/tests/data/fixtures/combining/11.json
index 6757b45..14822ed 100644
--- a/tests/data/fixtures/combining/11.json
+++ b/tests/data/fixtures/combining/11.json
@@ -243,7 +243,7 @@
}
},
"cursor_position": [
- 1,
- 0
+ 0,
+ 80
]
} \ No newline at end of file
diff --git a/tests/data/fixtures/ri.in b/tests/data/fixtures/ri.in
index 124a807..9e8d246 100644
--- a/tests/data/fixtures/ri.in
+++ b/tests/data/fixtures/ri.in
@@ -1,3 +1,6 @@
foo\nbar\x1bMbaz
\x1bc1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24
\x1b[H\x1bM
+\x1bc
+\x1b[1;80Ha\x7f\x1b[3Hb\x1b[H
+\x1bM
diff --git a/tests/data/fixtures/ri/4.json b/tests/data/fixtures/ri/4.json
new file mode 100644
index 0000000..bb83ae4
--- /dev/null
+++ b/tests/data/fixtures/ri/4.json
@@ -0,0 +1,8 @@
+{
+ "contents": "",
+ "cells": {},
+ "cursor_position": [
+ 0,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/ri/4.typescript b/tests/data/fixtures/ri/4.typescript
new file mode 100644
index 0000000..c10be54
--- /dev/null
+++ b/tests/data/fixtures/ri/4.typescript
@@ -0,0 +1 @@
+c \ No newline at end of file
diff --git a/tests/data/fixtures/ri/5.json b/tests/data/fixtures/ri/5.json
new file mode 100644
index 0000000..e70e9fa
--- /dev/null
+++ b/tests/data/fixtures/ri/5.json
@@ -0,0 +1,15 @@
+{
+ "contents": " a\n\nb",
+ "cells": {
+ "0,79": {
+ "contents": "a"
+ },
+ "2,0": {
+ "contents": "b"
+ }
+ },
+ "cursor_position": [
+ 0,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/ri/5.typescript b/tests/data/fixtures/ri/5.typescript
new file mode 100644
index 0000000..69d759d
--- /dev/null
+++ b/tests/data/fixtures/ri/5.typescript
@@ -0,0 +1 @@
+ab \ No newline at end of file
diff --git a/tests/data/fixtures/ri/6.json b/tests/data/fixtures/ri/6.json
new file mode 100644
index 0000000..b58e830
--- /dev/null
+++ b/tests/data/fixtures/ri/6.json
@@ -0,0 +1,15 @@
+{
+ "contents": "\n a\n\nb",
+ "cells": {
+ "1,79": {
+ "contents": "a"
+ },
+ "3,0": {
+ "contents": "b"
+ }
+ },
+ "cursor_position": [
+ 0,
+ 0
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/ri/6.typescript b/tests/data/fixtures/ri/6.typescript
new file mode 100644
index 0000000..f963eed
--- /dev/null
+++ b/tests/data/fixtures/ri/6.typescript
@@ -0,0 +1 @@
+M \ No newline at end of file