@@ -567,21 +567,27 @@ func (e *editor) resetAndSend(content string) tea.Cmd {
567567 e .pendingFileRef = ""
568568 attachments := e .collectAttachments (content )
569569
570- // Sort attachments by name length descending to avoid partial matches
571- // e.g., replacing @paste-1 before @paste-10 would corrupt @paste-10.
572- slices .SortFunc (attachments , func (a , b messages.Attachment ) int {
573- return len (b .Name ) - len (a .Name )
574- })
575-
576570 var finalAttachments []messages.Attachment
571+ var pastes []messages.Attachment
572+
577573 for _ , att := range attachments {
578574 if att .Content != "" && strings .HasPrefix (att .Name , "paste-" ) {
579- content = strings . ReplaceAll ( content , "@" + att . Name , att . Content )
575+ pastes = append ( pastes , att )
580576 } else {
581577 finalAttachments = append (finalAttachments , att )
582578 }
583579 }
584580
581+ // Sort pastes by name length descending to avoid partial matches
582+ // e.g., replacing @paste-1 before @paste-10 would corrupt @paste-10.
583+ slices .SortFunc (pastes , func (a , b messages.Attachment ) int {
584+ return len (b .Name ) - len (a .Name )
585+ })
586+
587+ for _ , att := range pastes {
588+ content = strings .ReplaceAll (content , "@" + att .Name , att .Content )
589+ }
590+
585591 e .textarea .Reset ()
586592 e .userTyped = false
587593 e .clearSuggestion ()
0 commit comments