helix: Allow yank without a selection (#35612)

Related https://github.com/zed-industries/zed/issues/4642

Release Notes:
- Helix: without active selection, pressing `y` in helix mode will yank
a single character under cursor.

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Romans Malinovskis 2025-08-14 18:04:01 +01:00 committed by GitHub
parent 528d56e807
commit 20be133713
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 100 additions and 1 deletions

View file

@ -143,6 +143,16 @@ impl VimTestContext {
})
}
pub fn enable_helix(&mut self) {
self.cx.update(|_, cx| {
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings::<vim_mode_setting::HelixModeSetting>(cx, |s| {
*s = Some(true)
});
});
})
}
pub fn mode(&mut self) -> Mode {
self.update_editor(|editor, _, cx| editor.addon::<VimAddon>().unwrap().entity.read(cx).mode)
}
@ -210,6 +220,26 @@ impl VimTestContext {
assert_eq!(self.mode(), Mode::Normal, "{}", self.assertion_context());
assert_eq!(self.active_operator(), None, "{}", self.assertion_context());
}
pub fn shared_clipboard(&mut self) -> VimClipboard {
VimClipboard {
editor: self
.read_from_clipboard()
.map(|item| item.text().unwrap().to_string())
.unwrap_or_default(),
}
}
}
pub struct VimClipboard {
editor: String,
}
impl VimClipboard {
#[track_caller]
pub fn assert_eq(&self, expected: &str) {
assert_eq!(self.editor, expected);
}
}
impl Deref for VimTestContext {