diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-27 08:19:22 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-27 08:19:22 +0300 |
| commit | 4365542fc8c08f7ce11040fa62a94a78fba1c2e2 (patch) | |
| tree | 7b85b7314670ce50b2c4616147262d2987c6b584 /internal | |
| parent | 891e31f845d5a1d9fc7426eb8351a05c42fb1cd5 (diff) | |
flamegraph: extract heightMetricActive helper (yo)
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/tui/flamegraph/controls.go | 4 | ||||
| -rw-r--r-- | internal/tui/flamegraph/model.go | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/internal/tui/flamegraph/controls.go b/internal/tui/flamegraph/controls.go index 42c3e3e..c9e5484 100644 --- a/internal/tui/flamegraph/controls.go +++ b/internal/tui/flamegraph/controls.go @@ -234,3 +234,7 @@ func (m Model) heightFieldLabel() string { return m.heightField } } + +func (m Model) heightMetricActive() bool { + return strings.TrimSpace(m.heightField) != "" +} diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go index 9f14a70..7be2864 100644 --- a/internal/tui/flamegraph/model.go +++ b/internal/tui/flamegraph/model.go @@ -520,7 +520,7 @@ func (m Model) renderViewContent() string { FilterSet: m.filterVisible, GlobalTotal: m.globalTotal, MetricLabel: m.countFieldLabel(), - HeightMetricActive: strings.TrimSpace(m.heightField) != "", + HeightMetricActive: m.heightMetricActive(), IsDark: m.isDark, SearchQuery: m.searchQuery, }) @@ -1101,12 +1101,12 @@ func (m Model) rootSnapshotPath() string { // frameIndexAt delegates to the renderer package-level helper to convert // terminal coordinates (x, y) to a frame index, accounting for UI chrome. func (m Model) frameIndexAt(x, y int) int { - return frameIndexAt(m.frames, x, y, m.width, m.height, m.showHelp, strings.TrimSpace(m.heightField) != "") + return frameIndexAt(m.frames, x, y, m.width, m.height, m.showHelp, m.heightMetricActive()) } // frameCoordToTargetRow delegates to the renderer package-level helper. func (m Model) frameCoordToTargetRow(dataRow, availableRows int) int { - params := computeRenderParamsForAvailableRows(m.frames, availableRows, strings.TrimSpace(m.heightField) != "") + params := computeRenderParamsForAvailableRows(m.frames, availableRows, m.heightMetricActive()) return frameCoordToTargetRow(dataRow, params) } |
