From e863e3b62d232d650468cb5d1f9da925fb460f5e Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Wed, 10 Nov 2021 21:28:35 +0530 Subject: Ensure that identical keymaps stay in sync (#1056) Space mode and view mode are duplicated on two different keybinds, and they tend to get out of sync by contributers forgetting to update both of them. This commit adds a test that explicitly checks that they are identical. Prevents issues like #1050.--- helix-term/src/keymap.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'helix-term') diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 53e0d450..4fb0f172 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -802,4 +802,20 @@ mod tests { let node = keymap.root().search(&[crate::key!(' ')]).unwrap(); assert!(!node.node().unwrap().order().is_empty()) } + + #[test] + fn aliased_modes_are_same_in_default_keymap() { + let keymaps = Keymaps::default(); + let root = keymaps.get(&Mode::Normal).unwrap().root(); + assert_eq!( + root.search(&[key!(' '), key!('w')]).unwrap(), + root.search(&["C-w".parse::().unwrap()]).unwrap(), + "Mismatch for window mode on `Space-w` and `Ctrl-w`" + ); + assert_eq!( + root.search(&[key!('z')]).unwrap(), + root.search(&[key!('Z')]).unwrap(), + "Mismatch for view mode on `z` and `Z`" + ); + } } -- cgit v1.2.3-70-g09d2