vim: Fix gv after actions (#14829)

Fixes: #13720

Co-Authored-By: <tobbe@tlundberg.com>



Release Notes:

- vim: Fixed `gv` after `y`, `d`, etc.
([#13760](https://github.com/zed-industries/zed/issues/13760)).
This commit is contained in:
Conrad Irwin 2024-07-19 13:26:55 -06:00 committed by GitHub
parent 5e635b8914
commit d2efa12e16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 32 additions and 4 deletions

View file

@ -391,6 +391,15 @@ impl Vim {
self.stop_recording();
}
// When handling an action, you must create visual marks if you will switch to normal
// mode without the default selection behaviour.
fn store_visual_marks(&mut self, cx: &mut WindowContext) {
let mode = self.state().mode;
if mode.is_visual() {
create_visual_marks(self, mode, cx);
}
}
fn switch_mode(&mut self, mode: Mode, leave_selections: bool, cx: &mut WindowContext) {
let state = self.state();
let last_mode = state.mode;
@ -412,14 +421,14 @@ impl Vim {
// Sync editor settings like clip mode
self.sync_vim_settings(cx);
if !mode.is_visual() && last_mode.is_visual() {
create_visual_marks(self, last_mode, cx);
}
if leave_selections {
return;
}
if !mode.is_visual() && last_mode.is_visual() {
create_visual_marks(self, last_mode, cx);
}
// Adjust selections
self.update_active_editor(cx, |_, editor, cx| {
if last_mode != Mode::VisualBlock && last_mode.is_visual() && mode == Mode::VisualBlock