@@ -604,106 +604,6 @@ export const PromptInput = React.memo(function PromptInput({
604604 } ) ;
605605 }
606606
607- function handlePaste ( pastedText : string ) : void {
608- const totalChars = pastedText . length ;
609-
610- if ( totalChars <= 1000 ) {
611- const newlineCount = ( pastedText . match ( / \n / g) ?? [ ] ) . length ;
612- if ( newlineCount <= 9 ) {
613- const clean = pastedText
614- . replace ( / \r \n | \r / g, "\n" )
615- . replace ( / [ \x00 - \x08 \x0b \x0c \x0e - \x1f \x7f ] / g, "" )
616- . replace ( / \t / g, " " ) ;
617- updateBuffer ( ( s ) => insertText ( s , clean ) ) ;
618- return ;
619- }
620- }
621-
622- // Large paste: store raw text, insert marker with line/char count.
623- const lineCount = ( pastedText . match ( / \n / g) ?? [ ] ) . length + 1 ;
624- pasteCounterRef . current += 1 ;
625- const pasteId = pasteCounterRef . current ;
626- pastesRef . current . set ( pasteId , pastedText ) ;
627-
628- const marker =
629- lineCount > 10 ? `[paste #${ pasteId } +${ lineCount } lines]` : `[paste #${ pasteId } ${ totalChars } chars]` ;
630-
631- updateBuffer ( ( s ) => insertText ( s , marker ) ) ;
632- }
633-
634- function expandPasteMarkerAtCursor ( ) : void {
635- // First, try to collapse an already-expanded region at the cursor.
636- for ( const [ id , region ] of expandedRegionsRef . current ) {
637- if ( buffer . cursor >= region . start && buffer . cursor <= region . end ) {
638- // Collapse back to marker.
639- expandedRegionsRef . current . delete ( id ) ;
640- pastesRef . current . set ( id , region . content ) ;
641- setTimeout ( ( ) => {
642- updateBuffer ( ( s ) => {
643- const text = s . text . slice ( 0 , region . start ) + region . marker + s . text . slice ( region . end ) ;
644- return { text, cursor : region . start + region . marker . length } ;
645- } ) ;
646- } , 0 ) ;
647- return ;
648- }
649- }
650-
651- // No expanded region at cursor — try to expand a paste marker.
652- const marker = findPasteMarkerContaining ( buffer ) ;
653- if ( ! marker ) {
654- setStatusMessage ( t ( "ui.promptInput.noPasteMarker" ) ) ;
655- return ;
656- }
657- const content = pastesRef . current . get ( marker . id ) ;
658- if ( ! content ) {
659- setStatusMessage ( t ( "ui.promptInput.pasteNotFound" ) ) ;
660- return ;
661- }
662-
663- const pasteId = marker . id ;
664- const originalMarker = buffer . text . slice ( marker . start , marker . end ) ;
665- pastesRef . current . delete ( pasteId ) ;
666-
667- setTimeout ( ( ) => {
668- updateBuffer ( ( s ) => {
669- const text = s . text . slice ( 0 , marker . start ) + cleanPasteContent ( content ) + s . text . slice ( marker . end ) ;
670- const newEnd = marker . start + content . length ;
671- expandedRegionsRef . current . set ( pasteId , {
672- start : marker . start ,
673- end : newEnd ,
674- content,
675- marker : originalMarker ,
676- } ) ;
677- return { text, cursor : marker . start } ;
678- } ) ;
679- } , 0 ) ;
680- }
681-
682- function navigateHistory ( direction : - 1 | 1 ) : void {
683- if ( promptHistory . length === 0 ) {
684- return ;
685- }
686-
687- const previousCursor = historyCursor === - 1 ? promptHistory . length : historyCursor ;
688- const nextCursor = Math . max ( 0 , Math . min ( promptHistory . length , previousCursor + direction ) ) ;
689- const draft = historyCursor === - 1 ? buffer . text : draftBeforeHistory ;
690-
691- if ( historyCursor === - 1 ) {
692- setDraftBeforeHistory ( buffer . text ) ;
693- }
694-
695- if ( nextCursor === promptHistory . length ) {
696- const text = draft ?? "" ;
697- setBuffer ( { text, cursor : text . length } ) ;
698- setHistoryCursor ( - 1 ) ;
699- setDraftBeforeHistory ( null ) ;
700- return ;
701- }
702-
703- const text = promptHistory [ nextCursor ] ?? "" ;
704- setBuffer ( { text, cursor : text . length } ) ;
705- setHistoryCursor ( nextCursor ) ;
706- }
707607 function insertFileMentionSelection ( item : FileMentionItem ) : void {
708608 if ( ! fileMentionToken ) {
709609 return ;
0 commit comments