@@ -23,6 +23,8 @@ actions!(
2323 HelixInsert ,
2424 /// Appends at the end of the selection.
2525 HelixAppend ,
26+ /// Yanks the current selection or character if no selection.
27+ HelixYank ,
2628 /// Goes to the location of the last modification.
2729 HelixGotoLastModification ,
2830 ]
@@ -447,6 +449,47 @@ impl Vim {
447449 self . switch_mode ( Mode :: HelixNormal , true , window, cx) ;
448450 }
449451
452+ pub fn helix_yank ( & mut self , _: & HelixYank , window : & mut Window , cx : & mut Context < Self > ) {
453+ self . update_editor ( window, cx, |vim, editor, window, cx| {
454+ let has_selection = editor
455+ . selections
456+ . all_adjusted ( cx)
457+ . iter ( )
458+ . any ( |selection| !selection. is_empty ( ) ) ;
459+
460+ if !has_selection {
461+ // If no selection, expand to current character (like 'v' does)
462+ editor. change_selections ( Default :: default ( ) , window, cx, |s| {
463+ s. move_with ( |map, selection| {
464+ let head = selection. head ( ) ;
465+ let new_head = movement:: saturating_right ( map, head) ;
466+ selection. set_tail ( head, SelectionGoal :: None ) ;
467+ selection. set_head ( new_head, SelectionGoal :: None ) ;
468+ } ) ;
469+ } ) ;
470+ vim. yank_selections_content (
471+ editor,
472+ crate :: motion:: MotionKind :: Exclusive ,
473+ window,
474+ cx,
475+ ) ;
476+ editor. change_selections ( Default :: default ( ) , window, cx, |s| {
477+ s. move_with ( |_map, selection| {
478+ selection. collapse_to ( selection. start , SelectionGoal :: None ) ;
479+ } ) ;
480+ } ) ;
481+ } else {
482+ // Yank the selection(s)
483+ vim. yank_selections_content (
484+ editor,
485+ crate :: motion:: MotionKind :: Exclusive ,
486+ window,
487+ cx,
488+ ) ;
489+ }
490+ } ) ;
491+ }
492+
450493 pub fn helix_goto_last_modification (
451494 & mut self ,
452495 _: & HelixGotoLastModification ,
0 commit comments