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
This commit is contained in:
jneem 2025-04-06 01:55:23 +07:00 committed by GitHub
parent b9051e65d4
commit 9949512b64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(