Skip to content

Commit 14daf0e

Browse files
committed
Fix copying on mac
pbcopy doesn't carae about utf I guess so a bunch of utf characters are garbled when copied. Use the OSC52 ANSI escape sequence instead to have the terminal copy for us. Keep clipboard.WriteAll for max supoprt (even when the terminal doesn't support OSC52) Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent de728c3 commit 14daf0e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

pkg/tui/components/messages/messages.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,11 +841,14 @@ func (m *model) copySelectionToClipboard() tea.Cmd {
841841
return nil
842842
}
843843

844-
if err := clipboard.WriteAll(selectedText); err != nil {
845-
return core.CmdHandler(notification.ShowMsg{Text: "Failed to copy: " + err.Error(), Type: notification.TypeError})
846-
}
847-
848-
return core.CmdHandler(notification.ShowMsg{Text: "Text copied to clipboard"})
844+
return tea.Sequence(
845+
tea.SetClipboard(selectedText),
846+
func() tea.Msg {
847+
_ = clipboard.WriteAll(selectedText)
848+
return nil
849+
},
850+
notification.SuccessCmd("Text copied to clipboard"),
851+
)
849852
}
850853

851854
func (m *model) clearSelection() {

0 commit comments

Comments
 (0)