shortcut!: prevent panic if shortcut key $section is missing

memfd
Manos Pitsidianakis 2020-09-13 16:42:26 +03:00
parent f6d5c968ea
commit 315af9bc05
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 3 additions and 3 deletions

View File

@ -27,9 +27,9 @@ use melib::{MeliError, Result};
#[macro_export] #[macro_export]
macro_rules! shortcut { macro_rules! shortcut {
($key:ident == $shortcuts:ident[$section:expr][$val:literal]) => { ($key:ident == $shortcuts:ident[$section:expr][$val:literal]) => {
$shortcuts[$section] $shortcuts
.get($val) .get($section)
.map(|v| v == $key) .and_then(|s| s.get($val).map(|v| v == $key))
.unwrap_or(false) .unwrap_or(false)
}; };
} }