vim: Fix escape key switching back to default mode instead of normal mode (#31843)

Closes #31728

This PR introduced new setting `"helix_mode"`. Enabling which will
enable the `vim_mode` along with `helix` behavior.

This solves issue where `vim`'s `default_mode` was being used to switch
between mode instead of opening in `default_mode`.

When `helix_mode` is enabled switcing to `Normal mode` will now switch
to `HelixNormal`


Release Notes:

- Fixed - escape key not switching to normal mode when default_mode is
insert
- Added - `helix_mode` setting to enable/disable helix key bindings

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Sanjeev Shrestha 2025-06-19 03:11:12 +05:45 committed by GitHub
parent d2ca68bd5d
commit ab189b898d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 72 additions and 14 deletions

View file

@ -2,6 +2,8 @@ use crate::{Vim, state::Mode};
use editor::{Bias, Editor, scroll::Autoscroll};
use gpui::{Action, Context, Window, actions};
use language::SelectionGoal;
use settings::Settings;
use vim_mode_setting::HelixModeSetting;
actions!(vim, [NormalBefore, TemporaryNormal]);
@ -36,7 +38,11 @@ impl Vim {
});
});
});
self.switch_mode(self.default_mode(cx), false, window, cx);
if HelixModeSetting::get_global(cx).0 {
self.switch_mode(Mode::HelixNormal, false, window, cx);
} else {
self.switch_mode(Mode::Normal, false, window, cx);
}
return;
}