Allow the keybinding context to detect the terminal vi_mode (#26236)

Release Notes:

- Added support for detecting the vi_mode in the keybinding context. Now
we can define and use the keybinding when the terminal is in vi_mode.


https://github.com/user-attachments/assets/a927b6c9-c634-4739-9502-8457614d9a90
This commit is contained in:
iyht 2025-03-26 08:23:23 -07:00 committed by GitHub
parent d232150d67
commit 0a49ccbebf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -1911,6 +1911,10 @@ impl Terminal {
}
}
}
pub fn vi_mode_enabled(&self) -> bool {
self.vi_mode_enabled
}
}
// Helper function to convert a grid row to a string

View file

@ -590,6 +590,10 @@ impl TerminalView {
let mut dispatch_context = KeyContext::new_with_defaults();
dispatch_context.add("Terminal");
if self.terminal.read(cx).vi_mode_enabled() {
dispatch_context.add("vi_mode");
}
let mode = self.terminal.read(cx).last_content.mode;
dispatch_context.set(
"screen",