Merge pull request #1689 from mitchellh/macos-fs

macos: show alert when creating new tab in non-native fs
This commit is contained in:
Mitchell Hashimoto
2024-04-16 09:39:20 -07:00
committed by GitHub
2 changed files with 14 additions and 1 deletions

View File

@ -34,7 +34,7 @@ class TerminalController: NSWindowController, NSWindowDelegate,
}
/// Fullscreen state management.
private let fullscreenHandler = FullScreenHandler()
let fullscreenHandler = FullScreenHandler()
/// True when an alert is active so we don't overlap multiple.
private var alert: NSAlert? = nil

View File

@ -105,6 +105,19 @@ class TerminalManager {
}
private func newTab(to parent: NSWindow, withBaseConfig base: Ghostty.SurfaceConfiguration?) {
// If our parent is in non-native fullscreen, then new tabs do not work.
// See: https://github.com/mitchellh/ghostty/issues/392
if let controller = parent.windowController as? TerminalController,
controller.fullscreenHandler.isInNonNativeFullscreen {
let alert = NSAlert()
alert.messageText = "Cannot Create New Tab"
alert.informativeText = "New tabs are unsupported while in non-native fullscreen. Exit fullscreen and try again."
alert.addButton(withTitle: "OK")
alert.alertStyle = .warning
alert.beginSheetModal(for: parent)
return
}
// Create a new window and add it to the parent
let controller = createWindow(withBaseConfig: base)
let window = controller.window!