From 5b72dfff87a17f88905d98f0e8007a25ba128426 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 25 Sep 2025 23:57:01 +0200 Subject: [PATCH] helix: Streamline mode naming in the UI and in settings (#38870) Release Notes: - When `helix_mode = true`, modes are called without the `HELIX_` prefix in the UI: `HELIX_NORMAL` becomes `NORMAL` `HELIX_SELECT` becomes `SELECT` - (breaking change) Helix users should remove `"default_mode": "helix_normal"` from their settings. This is now the default when `"helix_mode": true`. --- assets/settings/default.json | 1 + crates/settings/src/settings_content.rs | 1 - crates/vim/src/state.rs | 4 ++-- crates/vim/src/vim.rs | 22 +++++++++++++++------- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 4e037aa679..298bce8245 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -115,6 +115,7 @@ // Whether to enable vim modes and key bindings. "vim_mode": false, // Whether to enable helix mode and key bindings. + // Enabling this mode will automatically enable vim mode. "helix_mode": false, // Whether to show the informational hover box when moving the mouse // over symbols in the editor. diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rs index 3651409130..eb84bc68cc 100644 --- a/crates/settings/src/settings_content.rs +++ b/crates/settings/src/settings_content.rs @@ -593,7 +593,6 @@ pub enum ModeContent { #[default] Normal, Insert, - HelixNormal, } /// Controls when to use system clipboard. diff --git a/crates/vim/src/state.rs b/crates/vim/src/state.rs index ca3be77a85..80f96523ab 100644 --- a/crates/vim/src/state.rs +++ b/crates/vim/src/state.rs @@ -59,8 +59,8 @@ impl Display for Mode { Mode::Visual => write!(f, "VISUAL"), Mode::VisualLine => write!(f, "VISUAL LINE"), Mode::VisualBlock => write!(f, "VISUAL BLOCK"), - Mode::HelixNormal => write!(f, "HELIX NORMAL"), - Mode::HelixSelect => write!(f, "HELIX SELECT"), + Mode::HelixNormal => write!(f, "NORMAL"), + Mode::HelixSelect => write!(f, "SELECT"), } } } diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 26c7535bc3..3e09108aee 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -424,14 +424,23 @@ impl Vim { pub fn new(window: &mut Window, cx: &mut Context) -> Entity { let editor = cx.entity(); - let mut initial_mode = VimSettings::get_global(cx).default_mode; - if initial_mode == Mode::Normal && HelixModeSetting::get_global(cx).0 { - initial_mode = Mode::HelixNormal; - } + let initial_vim_mode = VimSettings::get_global(cx).default_mode; + let (mode, last_mode) = if HelixModeSetting::get_global(cx).0 { + let initial_helix_mode = match initial_vim_mode { + Mode::Normal => Mode::HelixNormal, + Mode::Insert => Mode::Insert, + // Otherwise, we panic with a note that we should never get there due to the + // possible values of VimSettings::get_global(cx).default_mode being either Mode::Normal or Mode::Insert. + _ => unreachable!("Invalid default mode"), + }; + (initial_helix_mode, Mode::HelixNormal) + } else { + (initial_vim_mode, Mode::Normal) + }; cx.new(|cx| Vim { - mode: initial_mode, - last_mode: Mode::Normal, + mode, + last_mode, temp_mode: false, exit_temporary_mode: false, operator_stack: Vec::new(), @@ -1845,7 +1854,6 @@ impl From for Mode { match mode { ModeContent::Normal => Self::Normal, ModeContent::Insert => Self::Insert, - ModeContent::HelixNormal => Self::HelixNormal, } } }