summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/zoom.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-05 22:39:21 +0200
committerPaul Buetow <paul@buetow.org>2026-03-05 22:39:21 +0200
commit4e464d082e0c83f33f4b4659859b8a9be58987e1 (patch)
tree4005e44389c67e0d1daa64dfbe032d096c78f129 /internal/tui/flamegraph/zoom.go
parent3307447e4ae159b11bbe262ad161d6e3c571ee4c (diff)
task 359: add flamegraph zoom interactions
Diffstat (limited to 'internal/tui/flamegraph/zoom.go')
-rw-r--r--internal/tui/flamegraph/zoom.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/zoom.go b/internal/tui/flamegraph/zoom.go
new file mode 100644
index 0000000..7a3aa42
--- /dev/null
+++ b/internal/tui/flamegraph/zoom.go
@@ -0,0 +1,39 @@
+package flamegraph
+
+import "strings"
+
+func findNodeByPath(root *snapshotNode, path string) *snapshotNode {
+ if root == nil {
+ return nil
+ }
+ if path == "" {
+ return root
+ }
+ parts := strings.Split(path, pathSeparator)
+ if len(parts) == 0 {
+ return root
+ }
+ rootName := frameName(root.Name, 0)
+ if parts[0] == rootName {
+ parts = parts[1:]
+ }
+
+ node := root
+ for _, part := range parts {
+ next := findChildByName(node, part)
+ if next == nil {
+ return nil
+ }
+ node = next
+ }
+ return node
+}
+
+func findChildByName(node *snapshotNode, name string) *snapshotNode {
+ for _, child := range node.Children {
+ if child.Name == name || frameName(child.Name, 1) == name {
+ return child
+ }
+ }
+ return nil
+}