From 315af9bc052583ffc09e91a14270e1b8b5661c22 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 13 Sep 2020 16:42:26 +0300 Subject: [PATCH] shortcut!: prevent panic if shortcut key $section is missing --- src/conf/shortcuts.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/shortcuts.rs b/src/conf/shortcuts.rs index 031b08787..6c40ee74b 100644 --- a/src/conf/shortcuts.rs +++ b/src/conf/shortcuts.rs @@ -27,9 +27,9 @@ use melib::{MeliError, Result}; #[macro_export] macro_rules! shortcut { ($key:ident == $shortcuts:ident[$section:expr][$val:literal]) => { - $shortcuts[$section] - .get($val) - .map(|v| v == $key) + $shortcuts + .get($section) + .and_then(|s| s.get($val).map(|v| v == $key)) .unwrap_or(false) }; }