avoid panics in a couple of cases
test case: `cat /dev/random` refs: https://github.com/wez/wezterm/issues/769
This commit is contained in:
1 parent
ff153ba27f
commit
f9a6e265e9
2 files changed
+19
-13
No files matched your search
+15
-11
@@ -2361,18 +2361,22 @@ impl TerminalState {
|
||||
let line_idx = screen.phys_row(y);
|
||||
let line = screen.line_mut(line_idx);
|
||||
|
||||
let candidate = &line.cells()[to_copy];
|
||||
if candidate.str() == " " && to_copy > 0 {
|
||||
// It's a blank. It may be the second part of
|
||||
// a double-wide pair; look ahead of it.
|
||||
let prior = &line.cells()[to_copy - 1];
|
||||
if prior.width() > 1 {
|
||||
prior.clone()
|
||||
} else {
|
||||
candidate.clone()
|
||||
match line.cells().get(to_copy).cloned() {
|
||||
None => Cell::new(' ', CellAttributes::default()),
|
||||
Some(candidate) => {
|
||||
if candidate.str() == " " && to_copy > 0 {
|
||||
// It's a blank. It may be the second part of
|
||||
// a double-wide pair; look ahead of it.
|
||||
let prior = &line.cells()[to_copy - 1];
|
||||
if prior.width() > 1 {
|
||||
prior.clone()
|
||||
} else {
|
||||
candidate
|
||||
}
|
||||
} else {
|
||||
candidate
|
||||
}
|
||||
}
|
||||
} else {
|
||||
candidate.clone()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -399,8 +399,10 @@ impl Line {
|
||||
|
||||
pub fn erase_cell_with_margin(&mut self, x: usize, right_margin: usize) {
|
||||
self.invalidate_implicit_hyperlinks();
|
||||
self.invalidate_grapheme_at_or_before(x);
|
||||
self.cells.remove(x);
|
||||
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());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user