Fix new tab not created on Quick Terminal

This commit is contained in:
Soh Satoh
2025-01-25 20:29:04 +09:00
parent 25415f5dd0
commit f32adf3afa
2 changed files with 11 additions and 2 deletions

View File

@ -68,7 +68,7 @@ class QuickTerminalController: BaseTerminalController {
object: nil)
center.addObserver(
self,
selector: #selector(onNewTab(_:)),
selector: #selector(onNewTab),
name: Ghostty.Notification.ghosttyNewTab,
object: nil)
center.addObserver(
@ -539,7 +539,13 @@ class QuickTerminalController: BaseTerminalController {
syncAppearance()
}
@objc func onNewTab(_ sender: Any?) {
@objc func onNewTab(notification: SwiftUI.Notification) {
guard let surfaceView = notification.object as? Ghostty.SurfaceView else { return }
guard let window = surfaceView.window else { return }
// return if window is not in our managed windows
guard window == self.window else { return }
tabManager.newTab()
}

View File

@ -329,6 +329,9 @@ class TerminalManager {
guard let surfaceView = notification.object as? Ghostty.SurfaceView else { return }
guard let window = surfaceView.window else { return }
// return if window is not in our managed windows
guard windows.contains(where: { $0.controller.window == window }) else { return }
let configAny = notification.userInfo?[Ghostty.Notification.NewSurfaceConfigKey]
let config = configAny as? Ghostty.SurfaceConfiguration