Compare commits

...
Author SHA1 Message Date
Gnanam 8b7b8296ac tui: migrate off the deprecated Bubble Tea mouse Type API (SA1019)
The mouse classification helpers checked both the current Button/Action pair and
the deprecated msg.Type / tea.Mouse* constants. Bubble Tea's parser always
populates Button+Action and only DERIVES Type from them, so the Type fallbacks
were pure redundancy (a left-button drag is Action==Motion, already covered by
mouseMotion). Drop them — clears all 11 SA1019 findings in internal/tui with no
behavior change. The left-drag test now asserts the Action==Motion path directly.

Gates: gofmt/vet/build(host+linux+windows)/test -race/staticcheck(SA1019 0)/
deadcode(no new) all pass.
2026-06-15 19:08:26 +05:30
2 changed files with 11 additions and 12 deletions

No files matched your search

+9 -9
View File
@@ -170,28 +170,28 @@ func (m model) syncMouseCapture() (model, tea.Cmd) {
return m, tea.DisableMouse
}
// Bubble Tea's Type field is deprecated, but its parser still populates it for
// compatibility cases such as left-button drag events. Keep these helpers
// tolerant of both the current Button/Action pair and legacy Type values.
// Mouse classification uses the current Button/Action pair only. Bubble Tea's
// parser always populates Button+Action and merely derives the deprecated Type
// field from them, so checking Type adds nothing — and a left-button drag is
// Action==Motion (which mouseMotion already covers), not a press.
func mouseLeftPress(msg tea.MouseMsg) bool {
return msg.Button == tea.MouseButtonLeft && msg.Action == tea.MouseActionPress ||
msg.Type == tea.MouseLeft && msg.Action == tea.MouseActionPress
return msg.Button == tea.MouseButtonLeft && msg.Action == tea.MouseActionPress
}
func mouseMotion(msg tea.MouseMsg) bool {
return msg.Action == tea.MouseActionMotion || msg.Type == tea.MouseMotion
return msg.Action == tea.MouseActionMotion
}
func mouseRelease(msg tea.MouseMsg) bool {
return msg.Action == tea.MouseActionRelease || msg.Type == tea.MouseRelease
return msg.Action == tea.MouseActionRelease
}
func mouseWheelUp(msg tea.MouseMsg) bool {
return msg.Button == tea.MouseButtonWheelUp || msg.Type == tea.MouseWheelUp
return msg.Button == tea.MouseButtonWheelUp
}
func mouseWheelDown(msg tea.MouseMsg) bool {
return msg.Button == tea.MouseButtonWheelDown || msg.Type == tea.MouseWheelDown
return msg.Button == tea.MouseButtonWheelDown
}
func (m model) mouseOverComposer(msg tea.MouseMsg) bool {
+2 -3
View File
@@ -348,12 +348,11 @@ func TestTranscriptSelectionLeftDragDoesNotResetAnchor(t *testing.T) {
Y: 1,
})
m = updated.(model)
// Bubble Tea marks left-button drag motion as Type MouseLeft for backward
// compatibility; this must update the cursor without resetting the anchor.
// A left-button drag is Action==Motion with Button==Left; this must update the
// cursor without resetting the selection anchor.
updated, _ = m.Update(tea.MouseMsg{
Button: tea.MouseButtonLeft,
Action: tea.MouseActionMotion,
Type: tea.MouseLeft,
X: 8,
Y: 1,
})