From d9c4bd7e25d8f1ef4315ca91bb7c9fbaf74dafa0 Mon Sep 17 00:00:00 2001 From: Ryota Date: Fri, 12 Jan 2024 00:52:17 +0000 Subject: [PATCH] Add helper functions for finding root --- macos/Sources/Ghostty/Ghostty.SplitNode.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/macos/Sources/Ghostty/Ghostty.SplitNode.swift b/macos/Sources/Ghostty/Ghostty.SplitNode.swift index d9403b62f..daf059864 100644 --- a/macos/Sources/Ghostty/Ghostty.SplitNode.swift +++ b/macos/Sources/Ghostty/Ghostty.SplitNode.swift @@ -264,6 +264,13 @@ extension Ghostty { return weight } + /// Returns the top most parent, or this container. Because this + /// would fall back to use to self, the return value is guaranteed. + func rootContainer() -> Container { + guard let parent = self.parent else { return self } + return parent.rootContainer() + } + // MARK: - Hashable func hash(into hasher: inout Hasher) {