Add KeyContextView (#19872)

Release Notes:

- Added `cmd-shift-p debug: Open Key Context View` to help debug custom
key bindings



https://github.com/user-attachments/assets/de273c97-5b27-45aa-9ff1-f943b0ed7dfe
This commit is contained in:
Conrad Irwin 2024-10-30 11:26:54 -06:00 committed by GitHub
parent cf7b0c8971
commit ce5222f1df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 390 additions and 8 deletions

View file

@ -75,6 +75,18 @@ impl Keymap {
.filter(move |binding| binding.action().partial_eq(action))
}
/// all bindings for input returns all bindings that might match the input
/// (without checking context)
pub fn all_bindings_for_input(&self, input: &[Keystroke]) -> Vec<KeyBinding> {
self.bindings()
.rev()
.filter_map(|binding| {
binding.match_keystrokes(input).filter(|pending| !pending)?;
Some(binding.clone())
})
.collect()
}
/// bindings_for_input returns a list of bindings that match the given input,
/// and a boolean indicating whether or not more bindings might match if
/// the input was longer.