From 97b2249608e34b78d9a00e691fbd554fe23d7486 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Sat, 22 Nov 2025 13:38:36 -0500 Subject: [PATCH] Revert "fix(cmd): initialize clipboard in newApplication func (#625)" This reverts commit f2819e86d39568c2a4d43d4bc77900640b77b017. --- cmd/application.go | 8 ++------ cmd/message_input.go | 18 +++++++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/application.go b/cmd/application.go index e93a97a..96efc7c 100644 --- a/cmd/application.go +++ b/cmd/application.go @@ -1,9 +1,9 @@ package cmd import ( - "fmt" "log/slog" "strings" + "fmt" "github.com/ayn2op/discordo/internal/config" "github.com/ayn2op/discordo/internal/keyring" @@ -44,10 +44,6 @@ func newApplication(cfg *config.Config) *application { messageInput: newMessageInput(cfg), } - if err := clipboard.Init(); err != nil { - app.onError("Failed to init clipboard", err) - } - app.pages.SetInputCapture(app.onPagesInputCapture) app. EnableMouse(cfg.Mouse). @@ -246,7 +242,7 @@ func (a *application) showConfirmModal(prompt string, buttons []string, onDone f } func (a *application) showErrorModal(msg, err string, info ...any) { - a.showModal("[ ERROR ]", msg+"\nReason: "+err, []string{"Copy", "OK"}, func(label string) { + a.showModal("[ ERROR ]", msg + "\nReason: " + err, []string{"Copy", "OK"}, func(label string) { if label != "Copy" { return } diff --git a/cmd/message_input.go b/cmd/message_input.go index 3a424e8..4385dbe 100644 --- a/cmd/message_input.go +++ b/cmd/message_input.go @@ -58,13 +58,17 @@ func newMessageInput(cfg *config.Config) *messageInput { mentionsList: tview.NewList(), } - mi. - SetClipboard(func(s string) { - clipboard.Write(clipboard.FmtText, []byte(s)) - }, func() string { - data := clipboard.Read(clipboard.FmtText) - return string(data) - }) + if err := clipboard.Init(); err != nil { + app.onError("Failed to init clipboard", err) + } else { + mi. + SetClipboard(func(s string) { + clipboard.Write(clipboard.FmtText, []byte(s)) + }, func() string { + data := clipboard.Read(clipboard.FmtText) + return string(data) + }) + } mi.Box = ui.ConfigureBox(mi.Box, &cfg.Theme) mi.SetInputCapture(mi.onInputCapture)