summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-07-21 11:27:15 -0400
committerDax Raad <[email protected]>2025-07-21 11:27:15 -0400
commit6867658c0ff7b6d9d1d167ff8394c135b740877c (patch)
tree9ad2c47f1770c6367ca88b81ffac11ba773335ae
parentb8620395cbddba9fd2ba42ada2db55a81822eaa4 (diff)
downloadopencode-6867658c0ff7b6d9d1d167ff8394c135b740877c.tar.gz
opencode-6867658c0ff7b6d9d1d167ff8394c135b740877c.zip
do not copy empty strings
-rw-r--r--packages/tui/internal/components/chat/messages.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go
index d0be14b7f..ff7c33517 100644
--- a/packages/tui/internal/components/chat/messages.go
+++ b/packages/tui/internal/components/chat/messages.go
@@ -56,10 +56,6 @@ type selection struct {
endY int
}
-func (s selection) hasCompleteSelection() bool {
- return s.startX >= 0 && s.startY >= 0 && s.endX >= 0 && s.endY >= 0
-}
-
func (s selection) coords(offset int) *selection {
// selecting backwards
if s.startY > s.endY && s.endY >= 0 {
@@ -127,11 +123,13 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
case tea.MouseReleaseMsg:
- if m.selection != nil && m.selection.hasCompleteSelection() {
+ if m.selection != nil && len(m.clipboard) > 0 {
+ content := strings.Join(m.clipboard, "\n")
m.selection = nil
+ m.clipboard = []string{}
return m, tea.Sequence(
m.renderView(),
- app.SetClipboard(strings.Join(m.clipboard, "\n")),
+ app.SetClipboard(content),
toast.NewSuccessToast("Copied to clipboard"),
)
}