@@ -59,6 +59,7 @@ export function createCopyMode(input: {
5959 toBottom : ( ) => void
6060} ) {
6161 const [ state , setState ] = createSignal < CopyState > ( { ...empty } )
62+ const [ yankLineFlash , setYankLineFlash ] = createSignal < number | undefined > ( undefined )
6263
6364 // --- row building ---
6465
@@ -329,6 +330,7 @@ export function createCopyMode(input: {
329330 }
330331
331332 function exit ( ) {
333+ setYankLineFlash ( undefined )
332334 setState ( { ...empty } )
333335 input . toBottom ( )
334336 }
@@ -484,6 +486,23 @@ export function createCopyMode(input: {
484486 return { text, linewise : false }
485487 }
486488
489+ function yankLine ( ) {
490+ const list = rows ( )
491+ const s = state ( )
492+ const row = list [ s . idx ]
493+ if ( ! row ) return null
494+ const cache = new Map (
495+ input
496+ . scroll ( )
497+ . getChildren ( )
498+ . map ( ( c ) => [ c . id , c ] ) ,
499+ )
500+ const text = signedText ( row , cache )
501+ setYankLineFlash ( s . idx )
502+ setTimeout ( ( ) => setYankLineFlash ( undefined ) , 150 )
503+ return { text, linewise : true }
504+ }
505+
487506 async function copy ( ) {
488507 const text = selectionText ( )
489508 if ( ! text ) return
@@ -593,7 +612,36 @@ export function createCopyMode(input: {
593612
594613 const highlights = createMemo ( ( ) => {
595614 const s = state ( )
596- if ( ! s . visual || ! s . anchor ) return new Map < string , CopyHighlight [ ] > ( )
615+ const flashIdx = yankLineFlash ( )
616+ const out = new Map < string , CopyHighlight [ ] > ( )
617+
618+ // Handle yy flash highlight
619+ if ( flashIdx !== undefined ) {
620+ const list = rows ( )
621+ const row = list [ flashIdx ]
622+ if ( row ) {
623+ const cache = new Map (
624+ input
625+ . scroll ( )
626+ . getChildren ( )
627+ . map ( ( c ) => [ c . id , c ] ) ,
628+ )
629+ const text = rowText ( row , cache ) || ""
630+ const min = copyMin ( row , cache )
631+ const max = text . length > 0 ? min + text . length - 1 : min
632+ const cur = out . get ( row . id ) ?? [ ]
633+ cur . push ( {
634+ line : row . line ,
635+ left : min ,
636+ right : max ,
637+ text : text . slice ( Math . max ( 0 , min - min ) , Math . max ( 0 , max - min + 1 ) ) ,
638+ } )
639+ out . set ( row . id , cur )
640+ }
641+ }
642+
643+ // Handle visual mode highlights
644+ if ( ! s . visual || ! s . anchor ) return out
597645 const list = rows ( )
598646 const cache = new Map (
599647 input
@@ -605,7 +653,6 @@ export function createCopyMode(input: {
605653 const h = { idx : s . idx , col : s . col }
606654 const start = a . idx <= h . idx ? a : h
607655 const end = a . idx <= h . idx ? h : a
608- const out = new Map < string , CopyHighlight [ ] > ( )
609656 for ( let i = start . idx ; i <= end . idx ; i ++ ) {
610657 const r = list [ i ]
611658 if ( ! r ) continue
@@ -634,6 +681,7 @@ export function createCopyMode(input: {
634681 exit,
635682 visual,
636683 yank,
684+ yankLine,
637685 copy,
638686 isVisual : ( ) => ! ! state ( ) . visual ,
639687 exitVisual,
@@ -653,6 +701,7 @@ export function createCopyMode(input: {
653701 } ,
654702 row,
655703 highlights,
704+ yankLineFlash : ( ) => yankLineFlash ( ) ,
656705 active : ( ) => state ( ) . active ,
657706 clamp,
658707 state,
0 commit comments