fix: allow only one instance of help view on view stack

fixes #171
This commit is contained in:
Henrik Friedrichsen
2020-04-02 21:22:12 +02:00
parent 705a54c08c
commit 85bd4eda8a

View File

@@ -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<CommandResult, String> {
if let Command::Help = cmd {
Ok(CommandResult::Consumed(None))
} else {
Ok(CommandResult::Ignored)
}
}
}