vim: Add helix mode toggle (#41454)

Just for parity with vim. Also prevents these toggles from having both
enabled at the same time as that is a buggy state.

Release Notes:

- Added command to toggle helix mode
This commit is contained in:
Lukas Wirth
2025-10-29 12:16:31 +00:00
committed by GitHub
parent 1a223e23fb
commit b7d31fabc5
2 changed files with 35 additions and 3 deletions
+18 -2
View File
@@ -260,6 +260,8 @@ actions!(
[
/// Toggles Vim mode on or off.
ToggleVimMode,
/// Toggles Helix mode on or off.
ToggleHelixMode,
]
);
@@ -274,9 +276,23 @@ pub fn init(cx: &mut App) {
cx.observe_new(|workspace: &mut Workspace, _, _| {
workspace.register_action(|workspace, _: &ToggleVimMode, _, cx| {
let fs = workspace.app_state().fs.clone();
let currently_enabled = Vim::enabled(cx);
let currently_enabled = VimModeSetting::get_global(cx).0;
update_settings_file(fs, cx, move |setting, _| {
setting.vim_mode = Some(!currently_enabled)
setting.vim_mode = Some(!currently_enabled);
if let Some(helix_mode) = &mut setting.helix_mode {
*helix_mode = false;
}
})
});
workspace.register_action(|workspace, _: &ToggleHelixMode, _, cx| {
let fs = workspace.app_state().fs.clone();
let currently_enabled = HelixModeSetting::get_global(cx).0;
update_settings_file(fs, cx, move |setting, _| {
setting.helix_mode = Some(!currently_enabled);
if let Some(vim_mode) = &mut setting.vim_mode {
*vim_mode = false;
}
})
});