mirror of https://github.com/helix-editor/helix
Simplify labelled command pattern match
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>pull/3958/head
parent
a5d1c0571a
commit
0d307265f6
|
@ -217,19 +217,14 @@ impl<'de> serde::de::Visitor<'de> for KeyTrieVisitor {
|
||||||
|
|
||||||
match command {
|
match command {
|
||||||
None => Ok(KeyTrie::Node(KeyTrieNode::new(label, mapping, order))),
|
None => Ok(KeyTrie::Node(KeyTrieNode::new(label, mapping, order))),
|
||||||
Some(cmd) => {
|
Some(MappableCommand::Typable { name, args, .. }) if !label.is_empty() => {
|
||||||
let status = (cmd, label.is_empty());
|
Ok(KeyTrie::Leaf(MappableCommand::Typable {
|
||||||
if let (MappableCommand::Typable { name, args, .. }, false) = status {
|
name,
|
||||||
Ok(MappableCommand::Typable {
|
args,
|
||||||
name,
|
doc: label.to_string(),
|
||||||
args,
|
}))
|
||||||
doc: label.to_string(),
|
|
||||||
})
|
|
||||||
.map(KeyTrie::Leaf)
|
|
||||||
} else {
|
|
||||||
Ok(KeyTrie::Leaf(status.0))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Some(command) => Ok(KeyTrie::Leaf(command)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue