From 453ef3a6288a77a586e612e91d8bce4a61070528 Mon Sep 17 00:00:00 2001 From: lemo-o <21benjaminhall@gmail.com> Date: Tue, 20 Oct 2026 09:04:28 -0600 Subject: [PATCH] fixed copy-paste behavior --- internal/tui/data_test.go | 29 +++++++++++++++++++++++++++++ internal/tui/mouse.go | 13 +------------ internal/tui/scrollback_test.go | 16 +++++++++------- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/internal/tui/data_test.go b/internal/tui/data_test.go index 6503480..4122f75 100644 --- a/internal/tui/data_test.go +++ b/internal/tui/data_test.go @@ -347,6 +347,35 @@ func TestScrollingAPaneStaysInsideIt(t *testing.T) { } } +func TestABareArrowScrollsTheDataPage(t *testing.T) { + m, set := fixtureTUIWith(t, haFixtureYAML) + m.phase = phasePicking + m.mode = modeData + m.rebuildRows() + + el := set.Tenants[0].Elements[0] + next, cmd := m.openDataTabs([]sessionTarget{{eid: el.ID, name: el.Name, tsg: m.tenant.TSGID}}) + m = runDataLoads(t, next.(tuiModel), cmd) + m.phase = phaseData + m.height = 12 + + next, _ = m.onDataKey("down") + down := next.(tuiModel) + at := down.data[0].scroll + if at == 0 { + t.Fatal("down did not scroll the page; the wheel has nothing else to arrive as") + } + next, _ = down.onDataKey("up") + if got := next.(tuiModel).data[0].scroll; got >= at { + t.Errorf("scroll = %d after up, want below %d", got, at) + } + + if got := m.mouseMode(); got != tea.MouseModeNone { + t.Errorf("mouseMode() = %v; asking for the mouse here costs click-to-select and buys "+ + "nothing, since a notch already arrives as the arrow key above", got) + } +} + func paneRows(m tuiModel) int { _, rows := m.dataPaneSize() return rows diff --git a/internal/tui/mouse.go b/internal/tui/mouse.go index b132907..adc3a31 100644 --- a/internal/tui/mouse.go +++ b/internal/tui/mouse.go @@ -6,7 +6,7 @@ import ( func (m tuiModel) mouseMode() tea.MouseMode { switch m.phase { - case phaseSession, phaseData: + case phaseSession: return tea.MouseModeCellMotion } return tea.MouseModeNone @@ -30,17 +30,6 @@ func (m tuiModel) onWheel(up bool) (tea.Model, tea.Cmd) { next, _ = next.onScrollKey(s, key) } return next, nil - - case phaseData: - key := "down" - if up { - key = "up" - } - var model tea.Model = m - for range wheelStep { - model, _ = model.(tuiModel).onDataKey(key) - } - return model, nil } return m, nil } diff --git a/internal/tui/scrollback_test.go b/internal/tui/scrollback_test.go index 0ed3900..1f1bc23 100644 --- a/internal/tui/scrollback_test.go +++ b/internal/tui/scrollback_test.go @@ -153,17 +153,19 @@ func TestTypingReturnsThePaneToLive(t *testing.T) { func TestOnlyTheScrollingPanesAskForTheMouse(t *testing.T) { m, _ := scrolledPane(t) - for _, phase := range []tuiPhase{phasePicking, phaseResults, phaseMenu, phaseSettings, phaseMacros} { + for _, phase := range []tuiPhase{ + phasePicking, phaseResults, phaseMenu, phaseSettings, phaseMacros, phaseData, + } { m.phase = phase if got := m.mouseMode(); got != tea.MouseModeNone { - t.Errorf("phase %d mouseMode() = %v, want the terminal to keep the mouse", phase, got) + t.Errorf("phase %d mouseMode() = %v, want the terminal to keep the mouse so text "+ + "can be selected; a notch already arrives as an arrow key there", phase, got) } } - for _, phase := range []tuiPhase{phaseSession, phaseData} { - m.phase = phase - if got := m.mouseMode(); got == tea.MouseModeNone { - t.Errorf("phase %d asks for no mouse, so the wheel cannot reach it", phase) - } + m.phase = phaseSession + if got := m.mouseMode(); got == tea.MouseModeNone { + t.Error("the session pane asks for no mouse, so a notch recalls a command at the " + + "device prompt instead of scrolling") } }