From 4aaa784d8f9e96adb91c82c74ba35a95accf3436 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 25 Jul 2020 16:34:53 +0300 Subject: [PATCH] Fix panic on empty command history when browsing history --- src/components/utilities.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/utilities.rs b/src/components/utilities.rs index d5d7ff09..94968061 100644 --- a/src/components/utilities.rs +++ b/src/components/utilities.rs @@ -1102,6 +1102,9 @@ impl Component for StatusBar { self.dirty = true; } UIEvent::CmdInput(Key::Ctrl('p')) => { + if self.cmd_history.is_empty() { + return true; + } let pos = self.ex_buffer_cmd_history_pos.map(|p| p + 1).unwrap_or(0); let pos = Some(std::cmp::min(pos, self.cmd_history.len().saturating_sub(1))); if pos != self.ex_buffer_cmd_history_pos { @@ -1121,6 +1124,9 @@ impl Component for StatusBar { return true; } UIEvent::CmdInput(Key::Ctrl('n')) => { + if self.cmd_history.is_empty() { + return true; + } if Some(0) == self.ex_buffer_cmd_history_pos { self.ex_buffer_cmd_history_pos = None; self.ex_buffer.clear();