mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
fix(macos): prevent performing newTab shortcut on QuickTerminalWindow… (#5955)
Fixes #5939
This commit is contained in:
@ -59,6 +59,11 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
selector: #selector(ghosttyConfigDidChange(_:)),
|
selector: #selector(ghosttyConfigDidChange(_:)),
|
||||||
name: .ghosttyConfigDidChange,
|
name: .ghosttyConfigDidChange,
|
||||||
object: nil)
|
object: nil)
|
||||||
|
center.addObserver(
|
||||||
|
self,
|
||||||
|
selector: #selector(onNewTab),
|
||||||
|
name: Ghostty.Notification.ghosttyNewTab,
|
||||||
|
object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
@ -437,6 +442,16 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func showNoNewTabAlert() {
|
||||||
|
guard let window else { return }
|
||||||
|
let alert = NSAlert()
|
||||||
|
alert.messageText = "Cannot Create New Tab"
|
||||||
|
alert.informativeText = "Tabs aren't supported in the Quick Terminal."
|
||||||
|
alert.addButton(withTitle: "OK")
|
||||||
|
alert.alertStyle = .warning
|
||||||
|
alert.beginSheetModal(for: window)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: First Responder
|
// MARK: First Responder
|
||||||
|
|
||||||
@IBAction override func closeWindow(_ sender: Any) {
|
@IBAction override func closeWindow(_ sender: Any) {
|
||||||
@ -445,13 +460,7 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func newTab(_ sender: Any?) {
|
@IBAction func newTab(_ sender: Any?) {
|
||||||
guard let window else { return }
|
showNoNewTabAlert()
|
||||||
let alert = NSAlert()
|
|
||||||
alert.messageText = "Cannot Create New Tab"
|
|
||||||
alert.informativeText = "Tabs aren't supported in the Quick Terminal."
|
|
||||||
alert.addButton(withTitle: "OK")
|
|
||||||
alert.alertStyle = .warning
|
|
||||||
alert.beginSheetModal(for: window)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func toggleGhosttyFullScreen(_ sender: Any) {
|
@IBAction func toggleGhosttyFullScreen(_ sender: Any) {
|
||||||
@ -492,6 +501,14 @@ class QuickTerminalController: BaseTerminalController {
|
|||||||
syncAppearance()
|
syncAppearance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc private func onNewTab(notification: SwiftUI.Notification) {
|
||||||
|
guard let surfaceView = notification.object as? Ghostty.SurfaceView else { return }
|
||||||
|
guard let window = surfaceView.window else { return }
|
||||||
|
guard window.windowController is QuickTerminalController else { return }
|
||||||
|
// Tabs aren't supported with Quick Terminals or derivatives
|
||||||
|
showNoNewTabAlert()
|
||||||
|
}
|
||||||
|
|
||||||
private struct DerivedConfig {
|
private struct DerivedConfig {
|
||||||
let quickTerminalScreen: QuickTerminalScreen
|
let quickTerminalScreen: QuickTerminalScreen
|
||||||
let quickTerminalAnimationDuration: Double
|
let quickTerminalAnimationDuration: Double
|
||||||
|
@ -125,6 +125,9 @@ class TerminalManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func newTab(to parent: NSWindow, withBaseConfig base: Ghostty.SurfaceConfiguration?) {
|
private func newTab(to parent: NSWindow, withBaseConfig base: Ghostty.SurfaceConfiguration?) {
|
||||||
|
// Making sure that we're dealing with a TerminalController
|
||||||
|
guard parent.windowController is TerminalController else { return }
|
||||||
|
|
||||||
// If our parent is in non-native fullscreen, then new tabs do not work.
|
// If our parent is in non-native fullscreen, then new tabs do not work.
|
||||||
// See: https://github.com/mitchellh/ghostty/issues/392
|
// See: https://github.com/mitchellh/ghostty/issues/392
|
||||||
if let controller = parent.windowController as? TerminalController,
|
if let controller = parent.windowController as? TerminalController,
|
||||||
|
Reference in New Issue
Block a user