From 9949512b64ab2f472fc3426d853bc9bd0f6d94e2 Mon Sep 17 00:00:00 2001 From: jneem Date: Sun, 6 Apr 2025 01:55:23 +0700 Subject: [PATCH] Add a next_mode to vim::Paste instead of hard-coding Normal mode (#27897) This adds a `next_mode` parameter to the `vim::Paste` action. My main use-case for this is for helix users, who will want to switch into `HelixNormal` mode instead of `Normal` mode. I'm not sure if this is the best approach -- another possibility would be to have a global vim-vs-helix configuration, and then have every invocation of "normal" mode choose vim or helix based on that global configuration. But the approach in this PR is much less invasive. Release Notes: - vim: switch to the configured default mode after paste instead of hard-coding Normal mode --- crates/vim/src/normal/paste.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs index 3f3e27c457..d869a05e5c 100644 --- a/crates/vim/src/normal/paste.rs +++ b/crates/vim/src/normal/paste.rs @@ -3,10 +3,11 @@ use gpui::{Context, Window, impl_actions}; use language::{Bias, SelectionGoal}; use schemars::JsonSchema; use serde::Deserialize; +use settings::Settings; use std::cmp; use crate::{ - Vim, + Vim, VimSettings, motion::{Motion, MotionKind}, object::Object, state::{Mode, Register}, @@ -203,7 +204,8 @@ impl Vim { }) }); }); - self.switch_mode(Mode::Normal, true, window, cx); + let next_mode = VimSettings::get_global(cx).default_mode; + self.switch_mode(next_mode, true, window, cx); } pub fn replace_with_register_object(