From 8ca0024bfba8933652195ab5c86eb2fb6b6c1aeb Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 16 Jun 2021 08:35:09 -0700 Subject: [PATCH] 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 --- termwiz/src/surface/line.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/termwiz/src/surface/line.rs b/termwiz/src/surface/line.rs index ab391dd4e..640e1ab78 100644 --- a/termwiz/src/surface/line.rs +++ b/termwiz/src/surface/line.rs @@ -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);