From 22df28002f71c69a0d9be454f3e9367797aa41e2 Mon Sep 17 00:00:00 2001 From: Matthew Cheely Date: Tue, 15 Nov 2022 21:20:39 -0500 Subject: [PATCH] return errors for ambiguous and unsupported labels in menus --- helix-term/src/keymap.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 0c5931fb5632..56fe13b642b2 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -204,6 +204,12 @@ impl<'de> serde::de::Visitor<'de> for KeyTrieVisitor { match command { None => Ok(KeyTrie::Node(KeyTrieNode::new(label, mapping, order))), + Some(_command) if !order.is_empty() => { + Err(serde::de::Error::custom("ambiguous mapping: 'command' is only valid with 'label', but I found other keys")) + } + Some(MappableCommand::Static { .. }) if !label.is_empty() => { + Err(serde::de::Error::custom("custom labels are only available for typable commands (the ones starting with ':')")) + } Some(MappableCommand::Typable { name, args, .. }) if !label.is_empty() => { Ok(KeyTrie::Leaf(MappableCommand::Typable { name,