Skip to content

Commit 3f3da44

Browse files
authored
fix(tui): text selection is sometimes not cleared when click+release without dragging (sst#1993)
1 parent b3885d1 commit 3f3da44

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/tui/internal/components/chat/messages.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,18 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
134134
}
135135

136136
case tea.MouseReleaseMsg:
137-
if m.selection != nil && len(m.clipboard) > 0 {
138-
content := strings.Join(m.clipboard, "\n")
137+
if m.selection != nil {
139138
m.selection = nil
140-
m.clipboard = []string{}
141-
return m, tea.Sequence(
142-
m.renderView(),
143-
app.SetClipboard(content),
144-
toast.NewSuccessToast("Copied to clipboard"),
145-
)
139+
if len(m.clipboard) > 0 {
140+
content := strings.Join(m.clipboard, "\n")
141+
m.clipboard = []string{}
142+
return m, tea.Sequence(
143+
m.renderView(),
144+
app.SetClipboard(content),
145+
toast.NewSuccessToast("Copied to clipboard"),
146+
)
147+
}
148+
return m, m.renderView()
146149
}
147150
case tea.WindowSizeMsg:
148151
effectiveWidth := msg.Width - 4

0 commit comments

Comments
 (0)