From 85bd4eda8a26adf1a54cc9b033e5ceee99a50da6 Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Thu, 2 Apr 2020 21:22:12 +0200 Subject: [PATCH] fix: allow only one instance of help view on view stack fixes #171 --- src/ui/help.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ui/help.rs b/src/ui/help.rs index f63dd63..9ff12fd 100644 --- a/src/ui/help.rs +++ b/src/ui/help.rs @@ -4,8 +4,10 @@ use cursive::theme::Effect; use cursive::utils::markup::StyledString; use cursive::view::ViewWrapper; use cursive::views::{ScrollView, TextView}; +use cursive::Cursive; use crate::command::Command; +use crate::commands::CommandResult; use crate::config::config_path; use crate::traits::ViewExt; @@ -46,4 +48,12 @@ impl ViewExt for HelpView { fn title(&self) -> String { "Help".to_string() } + + fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result { + if let Command::Help = cmd { + Ok(CommandResult::Consumed(None)) + } else { + Ok(CommandResult::Ignored) + } + } }