mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: "+" button ensures tab is added to same window group
This commit is contained in:
@ -12,10 +12,8 @@ class PrimaryWindowController: NSWindowController {
|
|||||||
// This is required for the "+" button to show up in the tab bar to add a
|
// This is required for the "+" button to show up in the tab bar to add a
|
||||||
// new tab.
|
// new tab.
|
||||||
override func newWindowForTab(_ sender: Any?) {
|
override func newWindowForTab(_ sender: Any?) {
|
||||||
// TODO: specify our window so the tab is created in the proper window
|
guard let window = self.window else { preconditionFailure("Expected window to be loaded") }
|
||||||
// guard let window = self.window else { preconditionFailure("Expected window to be loaded") }
|
|
||||||
|
|
||||||
guard let manager = self.windowManager else { return }
|
guard let manager = self.windowManager else { return }
|
||||||
manager.addNewTab()
|
manager.addNewTab(to: window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,13 @@ class PrimaryWindowManager {
|
|||||||
|
|
||||||
func addNewTab() {
|
func addNewTab() {
|
||||||
guard let existingWindow = mainWindow() else { return }
|
guard let existingWindow = mainWindow() else { return }
|
||||||
|
addNewTab(to: existingWindow)
|
||||||
|
}
|
||||||
|
|
||||||
|
func addNewTab(to window: NSWindow) {
|
||||||
guard let controller = createWindowController() else { return }
|
guard let controller = createWindowController() else { return }
|
||||||
guard let newWindow = addManagedWindow(windowController: controller)?.window else { return }
|
guard let newWindow = addManagedWindow(windowController: controller)?.window else { return }
|
||||||
existingWindow.addTabbedWindow(newWindow, ordered: .above)
|
window.addTabbedWindow(newWindow, ordered: .above)
|
||||||
newWindow.makeKeyAndOrderFront(nil)
|
newWindow.makeKeyAndOrderFront(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user