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:
+18
-2
@@ -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;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user