diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-12-03 02:46:27 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-12-03 02:46:27 -0500 |
commit | c2a1180df6cb44d73abf0412e2c10efc4f0438f0 (patch) | |
tree | dae8fddbc7647656b7cbbaab33a21aded5196b3d | |
parent | 003a4d085fd4b99ac96f2bad8219b585732f18eb (diff) | |
download | vt100-rust-c2a1180df6cb44d73abf0412e2c10efc4f0438f0.tar.gz vt100-rust-c2a1180df6cb44d73abf0412e2c10efc4f0438f0.zip |
fix keeping cursor past end of line with diffs
-rw-r--r-- | src/row.rs | 6 | ||||
-rw-r--r-- | tests/data/fixtures/el.in | 2 | ||||
-rw-r--r-- | tests/data/fixtures/el/25.json | 15 | ||||
-rw-r--r-- | tests/data/fixtures/el/25.typescript | 1 | ||||
-rw-r--r-- | tests/data/fixtures/el/26.json | 12 | ||||
-rw-r--r-- | tests/data/fixtures/el/26.typescript | 1 |
6 files changed, 35 insertions, 2 deletions
@@ -446,8 +446,10 @@ impl Row { crate::term::EraseChar::new(1).write_buf(contents); } let end_cell = self.get(end_pos.col).unwrap(); - contents.extend(end_cell.contents().as_bytes()); - prev_pos.col += if end_cell.is_wide() { 2 } else { 1 }; + if end_cell.has_contents() { + contents.extend(end_cell.contents().as_bytes()); + prev_pos.col += if end_cell.is_wide() { 2 } else { 1 }; + } } (prev_pos, prev_attrs) diff --git a/tests/data/fixtures/el.in b/tests/data/fixtures/el.in index f5f679c..1c132bd 100644 --- a/tests/data/fixtures/el.in +++ b/tests/data/fixtures/el.in @@ -22,3 +22,5 @@ foo\x1b[5;5Hbarbar\x1b[10;10Hbazbaz\x1b[20;20Hquux \x1bc\x1b[1;80H\x1b[41ma\x1b[1K \x1bc\x1b[1;80H\x1b[41maa\x1b[1K \x1bc\x1b[41m\x1b[2J\x1b[1;80Haa\x1b[1K +\x1bc\x1b[1;80Hab\x1b[1;80Hc +\x1b[2K diff --git a/tests/data/fixtures/el/25.json b/tests/data/fixtures/el/25.json new file mode 100644 index 0000000..504426c --- /dev/null +++ b/tests/data/fixtures/el/25.json @@ -0,0 +1,15 @@ +{ + "contents": " cb", + "cells": { + "0,79": { + "contents": "c" + }, + "1,0": { + "contents": "b" + } + }, + "cursor_position": [ + 0, + 80 + ] +}
\ No newline at end of file diff --git a/tests/data/fixtures/el/25.typescript b/tests/data/fixtures/el/25.typescript new file mode 100644 index 0000000..40224c4 --- /dev/null +++ b/tests/data/fixtures/el/25.typescript @@ -0,0 +1 @@ +c[1;80Hab[1;80Hc
\ No newline at end of file diff --git a/tests/data/fixtures/el/26.json b/tests/data/fixtures/el/26.json new file mode 100644 index 0000000..661055f --- /dev/null +++ b/tests/data/fixtures/el/26.json @@ -0,0 +1,12 @@ +{ + "contents": "\nb", + "cells": { + "1,0": { + "contents": "b" + } + }, + "cursor_position": [ + 0, + 80 + ] +}
\ No newline at end of file diff --git a/tests/data/fixtures/el/26.typescript b/tests/data/fixtures/el/26.typescript new file mode 100644 index 0000000..d2e06ee --- /dev/null +++ b/tests/data/fixtures/el/26.typescript @@ -0,0 +1 @@ +[2K
\ No newline at end of file |