From 481f6d62265916992dd5b7d3cb3c98c48004372a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 3 Dec 2021 11:40:52 -0500 Subject: fix cell attrs when wrapped but no first cell contents on next line --- src/row.rs | 11 +++++++++++ tests/data/fixtures/il_dl.in | 1 + tests/data/fixtures/il_dl/21.json | 13 +++++++++++++ tests/data/fixtures/il_dl/21.typescript | 1 + 4 files changed, 26 insertions(+) create mode 100644 tests/data/fixtures/il_dl/21.json create mode 100644 tests/data/fixtures/il_dl/21.typescript 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 -- cgit v1.2.3-54-g00ecf