aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-03 11:40:52 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-03 11:40:52 -0500
commit481f6d62265916992dd5b7d3cb3c98c48004372a (patch)
tree14b6eab60b72f642759c5ad9e8867257a8e8ba52
parentc2a1180df6cb44d73abf0412e2c10efc4f0438f0 (diff)
downloadvt100-rust-481f6d62265916992dd5b7d3cb3c98c48004372a.tar.gz
vt100-rust-481f6d62265916992dd5b7d3cb3c98c48004372a.zip
fix cell attrs when wrapped but no first cell contents on next line
-rw-r--r--src/row.rs11
-rw-r--r--tests/data/fixtures/il_dl.in1
-rw-r--r--tests/data/fixtures/il_dl/21.json13
-rw-r--r--tests/data/fixtures/il_dl/21.typescript1
4 files changed, 26 insertions, 0 deletions
diff --git a/src/row.rs b/src/row.rs
index e666cb7..48c18eb 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -156,6 +156,11 @@ impl Row {
let first_cell = self.get(start).unwrap();
if wrapping && first_cell == &default_cell {
+ let default_attrs = default_cell.attrs();
+ if &prev_attrs != default_attrs {
+ default_attrs.write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *default_attrs;
+ }
contents.push(b' ');
crate::term::Backspace::default().write_buf(contents);
crate::term::EraseChar::new(1).write_buf(contents);
@@ -294,6 +299,12 @@ impl Row {
&& prev_pos.col
>= self.cols() - if prev_first_cell.is_wide() { 1 } else { 0 }
{
+ let first_cell_attrs = first_cell.attrs();
+ if &prev_attrs != first_cell_attrs {
+ first_cell_attrs
+ .write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *first_cell_attrs;
+ }
let mut cell_contents = prev_first_cell.contents();
let need_erase = if cell_contents.is_empty() {
cell_contents = " ".to_string();
diff --git a/tests/data/fixtures/il_dl.in b/tests/data/fixtures/il_dl.in
index f6ca5e0..86d41f8 100644
--- a/tests/data/fixtures/il_dl.in
+++ b/tests/data/fixtures/il_dl.in
@@ -18,3 +18,4 @@ cd
\x1bc\na\x1b[1;80Hb\x1b[M
\x1bc\x1b[1;80Haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\x1b[H
\x1b[L
+\x1bc\x1b[1;80H\x1b[1mab\x1b[M
diff --git a/tests/data/fixtures/il_dl/21.json b/tests/data/fixtures/il_dl/21.json
new file mode 100644
index 0000000..6463e89
--- /dev/null
+++ b/tests/data/fixtures/il_dl/21.json
@@ -0,0 +1,13 @@
+{
+ "contents": " a",
+ "cells": {
+ "0,79": {
+ "contents": "a",
+ "bold": true
+ }
+ },
+ "cursor_position": [
+ 1,
+ 1
+ ]
+} \ No newline at end of file
diff --git a/tests/data/fixtures/il_dl/21.typescript b/tests/data/fixtures/il_dl/21.typescript
new file mode 100644
index 0000000..87fc711
--- /dev/null
+++ b/tests/data/fixtures/il_dl/21.typescript
@@ -0,0 +1 @@
+cab \ No newline at end of file