diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-25 10:24:03 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-25 10:24:03 +0200 |
| commit | 39878a9cf79b74af493008f1006e66e8fd11457f (patch) | |
| tree | 1a1271c2334cc279770852d7f6d90a0973893ce5 /internal/tui | |
| parent | 1a094b919cf66c2c3643e621c0c0af3bf1c90fd9 (diff) | |
Route files scrolling to grouped-directory offset
Diffstat (limited to 'internal/tui')
| -rw-r--r-- | internal/tui/dashboard/model.go | 10 | ||||
| -rw-r--r-- | internal/tui/dashboard/model_test.go | 21 |
2 files changed, 31 insertions, 0 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go index 1a770f3..966e93e 100644 --- a/internal/tui/dashboard/model.go +++ b/internal/tui/dashboard/model.go @@ -175,6 +175,9 @@ func (m *Model) handleScrollKey(keyStr string) bool { case TabSyscalls: return scrollOffset(keyStr, &m.syscallsOffset, m.maxSyscallsRows()) case TabFiles: + if m.filesDirGrouped { + return scrollOffset(keyStr, &m.filesDirOffset, m.maxFilesDirRows()) + } return scrollOffset(keyStr, &m.filesOffset, m.maxFilesRows()) case TabProcesses: return scrollOffset(keyStr, &m.processesOffset, m.maxProcessesRows()) @@ -216,6 +219,13 @@ func (m Model) maxFilesRows() int { return m.latest.FilesCount() } +func (m Model) maxFilesDirRows() int { + if m.latest == nil { + return 0 + } + return len(aggregateFilesByDir(m.latest.Files())) +} + func (m Model) maxProcessesRows() int { if m.latest == nil { return 0 diff --git a/internal/tui/dashboard/model_test.go b/internal/tui/dashboard/model_test.go index 1f479ab..489c14b 100644 --- a/internal/tui/dashboard/model_test.go +++ b/internal/tui/dashboard/model_test.go @@ -140,6 +140,27 @@ func TestFilesTabScrollsWithJK(t *testing.T) { } } +func TestFilesTabGroupedScrollUsesDirectoryOffset(t *testing.T) { + m := NewModelWithConfig(nil, nil, 250, common.DefaultKeyMap()) + m.activeTab = TabFiles + m.filesDirGrouped = true + snap := statsengine.NewSnapshot(nil, nil, nil, nil, []statsengine.FileSnapshot{ + {Path: "/a/f1"}, + {Path: "/a/f2"}, + {Path: "/b/f3"}, + }, nil, statsengine.HistogramSnapshot{}, statsengine.HistogramSnapshot{}) + m.latest = &snap + + next, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'j'}}) + model := next.(Model) + if model.filesDirOffset != 1 { + t.Fatalf("expected grouped dir offset 1 after j, got %d", model.filesDirOffset) + } + if model.filesOffset != 0 { + t.Fatalf("expected flat files offset unchanged, got %d", model.filesOffset) + } +} + func TestDirGroupKeyTogglesOnlyOnFilesTab(t *testing.T) { m := NewModelWithConfig(nil, nil, 250, common.DefaultKeyMap()) m.activeTab = TabFiles |
