diff options
| author | Aram Drevekenin <aram@poor.dev> | 2021-04-21 17:07:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-21 17:07:49 +0200 |
| commit | fc2110ab684c435a5a567920976e344cb22f659d (patch) | |
| tree | 5998f64de19dd8eddba7408176650174cc716a4d /src | |
| parent | docs(changelog): fix date (diff) | |
| download | sl0ppij-fc2110ab684c435a5a567920976e344cb22f659d.tar.gz sl0ppij-fc2110ab684c435a5a567920976e344cb22f659d.tar.xz sl0ppij-fc2110ab684c435a5a567920976e344cb22f659d.zip | |
fix(stability): do not clear line if it's not there (#289)
* fix(stability): do not clear line if it's not there
* style(fmt): rustfmt
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/panes/grid.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/client/panes/grid.rs b/src/client/panes/grid.rs index 950c72de..c6dd201e 100644 --- a/src/client/panes/grid.rs +++ b/src/client/panes/grid.rs @@ -606,15 +606,17 @@ impl Grid { row.replace_beginning_with(line_part); } pub fn clear_all_after_cursor(&mut self, replace_with: TerminalCharacter) { - let cursor_row = self.viewport.get_mut(self.cursor.y).unwrap(); - cursor_row.truncate(self.cursor.x); - let mut replace_with_columns_in_cursor_row = vec![replace_with; self.width - self.cursor.x]; - cursor_row.append(&mut replace_with_columns_in_cursor_row); + if let Some(cursor_row) = self.viewport.get_mut(self.cursor.y).as_mut() { + cursor_row.truncate(self.cursor.x); + let mut replace_with_columns_in_cursor_row = + vec![replace_with; self.width - self.cursor.x]; + cursor_row.append(&mut replace_with_columns_in_cursor_row); - let replace_with_columns = vec![replace_with; self.width]; - self.replace_characters_in_line_after_cursor(replace_with); - for row in self.viewport.iter_mut().skip(self.cursor.y + 1) { - row.replace_columns(replace_with_columns.clone()); + let replace_with_columns = vec![replace_with; self.width]; + self.replace_characters_in_line_after_cursor(replace_with); + for row in self.viewport.iter_mut().skip(self.cursor.y + 1) { + row.replace_columns(replace_with_columns.clone()); + } } } pub fn clear_cursor_line(&mut self) { |
