mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-12-01 11:23:10 +03:00
Check for duplicate keys in default keymap
This commit is contained in:
parent
80036b8bd3
commit
f9e9efb3ec
@ -64,10 +64,11 @@ macro_rules! keymap {
|
|||||||
$(
|
$(
|
||||||
$(
|
$(
|
||||||
let _key = $key.parse::<::helix_view::input::KeyEvent>().unwrap();
|
let _key = $key.parse::<::helix_view::input::KeyEvent>().unwrap();
|
||||||
_map.insert(
|
let _duplicate = _map.insert(
|
||||||
_key,
|
_key,
|
||||||
keymap!(@trie $value)
|
keymap!(@trie $value)
|
||||||
);
|
);
|
||||||
|
debug_assert!(_duplicate.is_none(), "Duplicate key found: {:?}", _duplicate.unwrap());
|
||||||
_order.push(_key);
|
_order.push(_key);
|
||||||
)+
|
)+
|
||||||
)*
|
)*
|
||||||
@ -691,6 +692,22 @@ pub fn merge_keys(mut config: Config) -> Config {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
|
fn duplicate_keys_should_panic() {
|
||||||
|
keymap!({ "Normal mode"
|
||||||
|
"i" => normal_mode,
|
||||||
|
"i" => goto_definition,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_duplicate_keys_in_default_keymap() {
|
||||||
|
// will panic on duplicate keys, assumes that `Keymaps` uses keymap! macro
|
||||||
|
Keymaps::default();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn merge_partial_keys() {
|
fn merge_partial_keys() {
|
||||||
let config = Config {
|
let config = Config {
|
||||||
|
Loading…
Reference in New Issue
Block a user