termwiz: erase_cell could panic if erasing beyond EOL

A relatively recent commit made it possible for the cell storage
to be smaller than the viewport width.

Avoid panicking when erasing beyond the end of the cell storage.
We can simply NOP as that cell is already implictly erased.

closes: #847
This commit is contained in:
Wez Furlong committed 2021-06-16 08:35:09 -07:00
1 parent 1be3d016b1
commit 8ca0024bfb
1 file changed
+4
+4
View File
@@ -390,6 +390,10 @@ impl Line {
}
pub fn erase_cell(&mut self, x: usize) {
if x >= self.cells.len() {
// Already implicitly erased
return;
}
self.invalidate_implicit_hyperlinks();
self.invalidate_grapheme_at_or_before(x);
self.cells.remove(x);