From 93fb852d9b24c76ce7f7bb7ad5e30c7ecd53a496 Mon Sep 17 00:00:00 2001 From: Pete Schaffner Date: Wed, 7 Feb 2024 21:44:44 +0100 Subject: [PATCH] Add comments/docs and make method name clearer --- macos/Sources/Features/Terminal/TerminalWindow.swift | 5 ++++- macos/Sources/Helpers/NSView+Extension.swift | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalWindow.swift b/macos/Sources/Features/Terminal/TerminalWindow.swift index 050fbce69..457b3bd08 100644 --- a/macos/Sources/Features/Terminal/TerminalWindow.swift +++ b/macos/Sources/Features/Terminal/TerminalWindow.swift @@ -34,6 +34,9 @@ class TerminalWindow: NSWindow { // The tab bar controller ID from macOS static private let TabBarController = NSUserInterfaceItemIdentifier("_tabBarController") + // Look through the titlebar's view hierarchy and hide any of the internal + // views used to create a separator between the title/toolbar and unselected + // tabs in the tab bar. override func updateConstraintsIfNeeded() { super.updateConstraintsIfNeeded() @@ -41,7 +44,7 @@ class TerminalWindow: NSWindow { $0.className == "NSTitlebarContainerView" }) else { return } - for v in titlebarContainer.subviews(withClassName: "NSTitlebarSeparatorView") { + for v in titlebarContainer.descendants(withClassName: "NSTitlebarSeparatorView") { v.isHidden = true } } diff --git a/macos/Sources/Helpers/NSView+Extension.swift b/macos/Sources/Helpers/NSView+Extension.swift index 744517c23..8612c0417 100644 --- a/macos/Sources/Helpers/NSView+Extension.swift +++ b/macos/Sources/Helpers/NSView+Extension.swift @@ -1,8 +1,8 @@ import AppKit extension NSView { - - func subviews(withClassName name: String) -> [NSView] { + /// Recursively finds and returns descendant views that have the given class name. + func descendants(withClassName name: String) -> [NSView] { var result = [NSView]() for subview in subviews { @@ -10,7 +10,7 @@ extension NSView { result.append(subview) } - result += subview.subviews(withClassName: name) + result += subview.descendants(withClassName: name) } return result