mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 11:17:15 +03:00
term: fix DCH removing cells instead of setting to current bg color
refs: #789
This commit is contained in:
parent
e9f1c319e7
commit
67e8bdc5c2
@ -28,6 +28,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Fixed: ALT + Arrow, PageUp/PageDown, Ins, Del, Home, End incorrectly sent ESC prefixed key sequences. [#892](https://github.com/wez/wezterm/issues/892)
|
||||
* New: Added [SendKey](config/lua/keyassignment/SendKey.md) key assignment action that makes it more convenient to rebind the key input that is sent to a pane.
|
||||
* Fixed: Crash due to Out of Memory condition when the iTerm2 protocol was used to send excessively large PNG files [#1031](https://github.com/wez/wezterm/issues/1031)
|
||||
* Fixed: `DCH` sequence would remove cells and replace them with default-blank cells instead of blank-cells-with-current-bg-color. [#789](https://github.com/wez/wezterm/issues/789)
|
||||
|
||||
### 20210814-124438-54e29167
|
||||
|
||||
|
@ -319,10 +319,11 @@ impl Screen {
|
||||
y: VisibleRowIndex,
|
||||
right_margin: usize,
|
||||
seqno: SequenceNo,
|
||||
blank_attr: CellAttributes,
|
||||
) {
|
||||
let line_idx = self.phys_row(y);
|
||||
let line = self.line_mut(line_idx);
|
||||
line.erase_cell_with_margin(x, right_margin, seqno);
|
||||
line.erase_cell_with_margin(x, right_margin, seqno, blank_attr);
|
||||
}
|
||||
|
||||
/// Set a cell. the x and y coordinates are relative to the visible screeen
|
||||
|
@ -1708,9 +1708,10 @@ impl TerminalState {
|
||||
let right_margin = self.left_and_right_margins.end;
|
||||
let limit = (x + n as usize).min(right_margin);
|
||||
|
||||
let blank_attr = self.pen.clone_sgr_only();
|
||||
let screen = self.screen_mut();
|
||||
for _ in x..limit as usize {
|
||||
screen.erase_cell(x, y, right_margin, seqno);
|
||||
screen.erase_cell(x, y, right_margin, seqno, blank_attr.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,32 @@
|
||||
use super::*;
|
||||
use termwiz::color::AnsiColor;
|
||||
|
||||
/// In this issue, the `CSI 2 P` sequence incorrectly removed two
|
||||
/// cells from the line, leaving them effectively blank, when those
|
||||
/// two cells should have been erased to the current background
|
||||
/// color as set by `CSI 40 m`
|
||||
#[test]
|
||||
fn test_789() {
|
||||
let mut term = TestTerm::new(1, 8, 0);
|
||||
term.print("\x1b[40m\x1b[Kfoo\x1b[2P");
|
||||
|
||||
let black = CellAttributes::default()
|
||||
.set_background(AnsiColor::Black)
|
||||
.clone();
|
||||
let mut line = Line::from_text("foo", &black);
|
||||
line.resize(8, 0);
|
||||
for x in 3..8 {
|
||||
line.set_cell(x, Cell::blank_with_attrs(black.clone()), 0);
|
||||
}
|
||||
|
||||
assert_lines_equal(
|
||||
file!(),
|
||||
line!(),
|
||||
&term.screen().visible_lines(),
|
||||
&[line],
|
||||
Compare::TEXT | Compare::ATTRS,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vpa() {
|
||||
@ -76,14 +104,14 @@ fn test_dch() {
|
||||
term.print("hello world");
|
||||
term.cup(1, 0);
|
||||
term.print("\x1b[P");
|
||||
assert_visible_contents(&term, file!(), line!(), &["hllo world "]);
|
||||
assert_visible_contents(&term, file!(), line!(), &["hllo world "]);
|
||||
|
||||
term.cup(4, 0);
|
||||
term.print("\x1b[2P");
|
||||
assert_visible_contents(&term, file!(), line!(), &["hlloorld "]);
|
||||
assert_visible_contents(&term, file!(), line!(), &["hlloorld "]);
|
||||
|
||||
term.print("\x1b[-2P");
|
||||
assert_visible_contents(&term, file!(), line!(), &["hlloorld "]);
|
||||
assert_visible_contents(&term, file!(), line!(), &["hlloorld "]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -539,14 +539,23 @@ impl Line {
|
||||
self.update_last_change_seqno(seqno);
|
||||
}
|
||||
|
||||
pub fn erase_cell_with_margin(&mut self, x: usize, right_margin: usize, seqno: SequenceNo) {
|
||||
pub fn erase_cell_with_margin(
|
||||
&mut self,
|
||||
x: usize,
|
||||
right_margin: usize,
|
||||
seqno: SequenceNo,
|
||||
blank_attr: CellAttributes,
|
||||
) {
|
||||
self.invalidate_implicit_hyperlinks(seqno);
|
||||
if x < self.cells.len() {
|
||||
self.invalidate_grapheme_at_or_before(x);
|
||||
self.cells.remove(x);
|
||||
}
|
||||
if right_margin <= self.cells.len() {
|
||||
self.cells.insert(right_margin - 1, Cell::default());
|
||||
if right_margin <= self.cells.len() + 1
|
||||
/* we just removed one */
|
||||
{
|
||||
self.cells
|
||||
.insert(right_margin - 1, Cell::blank_with_attrs(blank_attr));
|
||||
}
|
||||
self.update_last_change_seqno(seqno);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user