diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-27 08:23:53 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-27 08:23:53 +0300 |
| commit | 2bca3ff0a5a00edd0dbb9e891a35c28faf27b21f (patch) | |
| tree | f4c1fb405028454b09c580e9829513e3308f928e | |
| parent | 44fa9635c64477fe2e5a1205dd68e82c7c6b6ce9 (diff) | |
flamegraph: include height/count in view cache key (2p)
| -rw-r--r-- | internal/tui/flamegraph/model.go | 4 | ||||
| -rw-r--r-- | internal/tui/flamegraph/model_test.go | 36 |
2 files changed, 40 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go index 7be2864..b73368f 100644 --- a/internal/tui/flamegraph/model.go +++ b/internal/tui/flamegraph/model.go @@ -36,6 +36,8 @@ type flameViewCacheKey struct { searchQuery string statusMessage string zoomPath string + countField string + heightField string searchActive bool showHelp bool paused bool @@ -559,6 +561,8 @@ func (m Model) currentViewCacheKey() flameViewCacheKey { searchQuery: m.searchQuery, statusMessage: m.statusMessage, zoomPath: m.zoomPath, + countField: m.countField, + heightField: m.heightField, searchActive: m.searchActive, showHelp: m.showHelp, paused: m.paused, diff --git a/internal/tui/flamegraph/model_test.go b/internal/tui/flamegraph/model_test.go index 80a86bb..f31a9a1 100644 --- a/internal/tui/flamegraph/model_test.go +++ b/internal/tui/flamegraph/model_test.go @@ -1103,6 +1103,42 @@ func TestNewModelAlignsHeightFieldToLiveTrie(t *testing.T) { } } +func TestCurrentViewCacheKeyChangesWhenCountFieldChanges(t *testing.T) { + m := NewModel(nil) + m.width = 120 + m.height = 20 + m.frames = []tuiFrame{{Name: "root", Path: "root"}} + + before := m.currentViewCacheKey() + m.countField = "bytes" + after := m.currentViewCacheKey() + + if before == after { + t.Fatalf("expected cache key to change when count field changes") + } + if got, want := after.countField, "bytes"; got != want { + t.Fatalf("expected cache key count field %q, got %q", want, got) + } +} + +func TestCurrentViewCacheKeyChangesWhenHeightFieldChanges(t *testing.T) { + m := NewModel(nil) + m.width = 120 + m.height = 20 + m.frames = []tuiFrame{{Name: "root", Path: "root"}} + + before := m.currentViewCacheKey() + m.heightField = "duration" + after := m.currentViewCacheKey() + + if before == after { + t.Fatalf("expected cache key to change when height field changes") + } + if got, want := after.heightField, "duration"; got != want { + t.Fatalf("expected cache key height field %q, got %q", want, got) + } +} + func TestControlHelpToggle(t *testing.T) { m := NewModel(nil) m = pressFlameKey(t, m, tea.KeyPressMsg{Code: []rune{'?'}[0], Text: "?"}) |
