on master help sign in
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.

commite863e3b62d232d650468cb5d1f9da925fb460f5e authorGokul Soumya <gokulps15@gmail.com> dateWed 10 Nov 2021, 21:28 (5 years ago) parentf9e9efb
1 file changed+16
helix-term/src/keymap.rs+16
helix-term/src/keymap.rs+16
@@ -802,4 +802,20 @@ mod tests {
802802 let node = keymap.root().search(&[crate::key!(' ')]).unwrap();
803803 assert!(!node.node().unwrap().order().is_empty())
804804 }
805+
806+ #[test]
807+ fn aliased_modes_are_same_in_default_keymap() {
808+ let keymaps = Keymaps::default();
809+ let root = keymaps.get(&Mode::Normal).unwrap().root();
810+ assert_eq!(
811+ root.search(&[key!(' '), key!('w')]).unwrap(),
812+ root.search(&["C-w".parse::<KeyEvent>().unwrap()]).unwrap(),
813+ "Mismatch for window mode on `Space-w` and `Ctrl-w`"
814+ );
815+ assert_eq!(
816+ root.search(&[key!('z')]).unwrap(),
817+ root.search(&[key!('Z')]).unwrap(),
818+ "Mismatch for view mode on `z` and `Z`"
819+ );
820+ }
805821}