diff options
| author | Yihui Khuu <[email protected]> | 2025-08-17 00:16:09 +1000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-16 09:16:09 -0500 |
| commit | 3f3da44ed9a23f98b869038dfa423d8caf0dacf1 (patch) | |
| tree | 506389c820204aed824a92f483dd8f3bd3fc2ad7 | |
| parent | b3885d1614a5bdfdb55b690d7039dfa05f2bab5c (diff) | |
| download | opencode-3f3da44ed9a23f98b869038dfa423d8caf0dacf1.tar.gz opencode-3f3da44ed9a23f98b869038dfa423d8caf0dacf1.zip | |
fix(tui): text selection is sometimes not cleared when click+release without dragging (#1993)
| -rw-r--r-- | packages/tui/internal/components/chat/messages.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go index 77a9b8100..375254668 100644 --- a/packages/tui/internal/components/chat/messages.go +++ b/packages/tui/internal/components/chat/messages.go @@ -134,15 +134,18 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } case tea.MouseReleaseMsg: - if m.selection != nil && len(m.clipboard) > 0 { - content := strings.Join(m.clipboard, "\n") + if m.selection != nil { m.selection = nil - m.clipboard = []string{} - return m, tea.Sequence( - m.renderView(), - app.SetClipboard(content), - toast.NewSuccessToast("Copied to clipboard"), - ) + if len(m.clipboard) > 0 { + content := strings.Join(m.clipboard, "\n") + m.clipboard = []string{} + return m, tea.Sequence( + m.renderView(), + app.SetClipboard(content), + toast.NewSuccessToast("Copied to clipboard"), + ) + } + return m, m.renderView() } case tea.WindowSizeMsg: effectiveWidth := msg.Width - 4 |
