fix(tui): text selection is sometimes not cleared when click+release without dragging (#1993)
This commit is contained in:
@@ -134,9 +134,10 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case tea.MouseReleaseMsg:
|
case tea.MouseReleaseMsg:
|
||||||
if m.selection != nil && len(m.clipboard) > 0 {
|
if m.selection != nil {
|
||||||
content := strings.Join(m.clipboard, "\n")
|
|
||||||
m.selection = nil
|
m.selection = nil
|
||||||
|
if len(m.clipboard) > 0 {
|
||||||
|
content := strings.Join(m.clipboard, "\n")
|
||||||
m.clipboard = []string{}
|
m.clipboard = []string{}
|
||||||
return m, tea.Sequence(
|
return m, tea.Sequence(
|
||||||
m.renderView(),
|
m.renderView(),
|
||||||
@@ -144,6 +145,8 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
toast.NewSuccessToast("Copied to clipboard"),
|
toast.NewSuccessToast("Copied to clipboard"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
return m, m.renderView()
|
||||||
|
}
|
||||||
case tea.WindowSizeMsg:
|
case tea.WindowSizeMsg:
|
||||||
effectiveWidth := msg.Width - 4
|
effectiveWidth := msg.Width - 4
|
||||||
// Clear cache on resize since width affects rendering
|
// Clear cache on resize since width affects rendering
|
||||||
|
|||||||
Reference in New Issue
Block a user