gpui: Prevent the same action name from being registered multiple times (#33359)

Also removes duplicate `editor::RevertFile` and `vim::HelixDelete`
actions

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-26 00:24:14 -06:00 committed by GitHub
parent d09c7eb317
commit 90c893747c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 32 deletions

View file

@ -3,14 +3,12 @@ use gpui::{Action, actions};
use gpui::{Context, Window};
use language::{CharClassifier, CharKind};
use crate::motion::MotionKind;
use crate::{Vim, motion::Motion, state::Mode};
actions!(vim, [HelixNormalAfter, HelixDelete]);
actions!(vim, [HelixNormalAfter]);
pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
Vim::action(editor, cx, Vim::helix_normal_after);
Vim::action(editor, cx, Vim::helix_delete);
}
impl Vim {
@ -292,27 +290,6 @@ impl Vim {
_ => self.helix_move_and_collapse(motion, times, window, cx),
}
}
pub fn helix_delete(&mut self, _: &HelixDelete, window: &mut Window, cx: &mut Context<Self>) {
self.store_visual_marks(window, cx);
self.update_editor(window, cx, |vim, editor, window, cx| {
// Fixup selections so they have helix's semantics.
// Specifically:
// - Make sure that each cursor acts as a 1 character wide selection
editor.transact(window, cx, |editor, window, cx| {
editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
s.move_with(|map, selection| {
if selection.is_empty() && !selection.reversed {
selection.end = movement::right(map, selection.end);
}
});
});
});
vim.copy_selections_content(editor, MotionKind::Exclusive, window, cx);
editor.insert("", window, cx);
});
}
}
#[cfg(test)]