Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
helix: Streamline mode naming in the UI and in settings (#38870)
Jakub Konka5b72dfff87a1
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 4e037aa6793..298bce82456 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.rsindex 3651409130d..eb84bc68cc6 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.rsindex ca3be77a854..80f96523ab3 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.rsindex 26c7535bc35..3e09108aee2 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<Editor>) -> Entity<Self> {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<settings::ModeContent> for Mode {match mode {ModeContent::Normal => Self::Normal,ModeContent::Insert => Self::Insert,- ModeContent::HelixNormal => Self::HelixNormal,}}}