Skip to content

Commit 8c21206

Browse files
committed
fix(tui): address PR #27 remaining review items
- Replace handledCmd nil-returning goroutine with pre-allocated handledNoop Msg to avoid per-call goroutine allocation - Extract mouse scroll step magic number 3 to mouseScrollStep constant (reuse existing definition from column.go)
1 parent a13fc4a commit 8c21206

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cmd/mxcli/tui/app.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ import (
1414
// chromeHeight is the vertical space consumed by tab bar (1) + hint bar (1) + status bar (1).
1515
const chromeHeight = 3
1616

17+
// handledNoop is a pre-allocated no-op Msg to avoid per-call goroutine allocation.
18+
var handledNoop tea.Msg = struct{}{}
19+
1720
// handledCmd is returned by handleBrowserAppKeys to signal that a key was
1821
// consumed without producing a follow-up message. Using a shared variable
1922
// avoids allocating a new closure on every handled keystroke.
20-
var handledCmd tea.Cmd = func() tea.Msg { return nil }
23+
var handledCmd tea.Cmd = func() tea.Msg { return handledNoop }
2124

2225
// compareFlashClearMsg is sent 1 s after a clipboard copy in compare view.
2326
type compareFlashClearMsg struct{}

cmd/mxcli/tui/contentview.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ func (v ContentView) Update(msg tea.Msg) (ContentView, tea.Cmd) {
172172
if msg.Action == tea.MouseActionPress {
173173
switch msg.Button {
174174
case tea.MouseButtonWheelUp:
175-
v.yOffset = clamp(v.yOffset-3, 0, v.maxOffset())
175+
v.yOffset = clamp(v.yOffset-mouseScrollStep, 0, v.maxOffset())
176176
case tea.MouseButtonWheelDown:
177-
v.yOffset = clamp(v.yOffset+3, 0, v.maxOffset())
177+
v.yOffset = clamp(v.yOffset+mouseScrollStep, 0, v.maxOffset())
178178
}
179179
}
180180
}

0 commit comments

Comments
 (0)