Skip to content

Commit

Permalink
return errors for ambiguous and unsupported labels in menus
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCheely committed Oct 21, 2023
1 parent e570edd commit 22df280
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 22df280

Please sign in to comment.