diff --git a/Sources/Workspace.swift b/Sources/Workspace.swift index b2c0ca68..4de67906 100644 --- a/Sources/Workspace.swift +++ b/Sources/Workspace.swift @@ -9017,8 +9017,28 @@ extension Workspace: BonsplitDelegate { @MainActor private func confirmClosePanel(for tabId: TabID) async -> Bool { let alert = NSAlert() + alert.messageText = String(localized: "dialog.closeTab.title", defaultValue: "Close tab?") - alert.informativeText = String(localized: "dialog.closeTab.message", defaultValue: "This will close the current tab.") + + let panelName: String? = { + guard let panelId = panelIdFromSurfaceId(tabId) else { return nil } + if let custom = panelCustomTitles[panelId], !custom.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { + return custom + } + if let title = panelTitles[panelId], !title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { + return title + } + if let dir = panelDirectories[panelId], !dir.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { + return (dir as NSString).lastPathComponent + } + return nil + }() + + if let panelName { + alert.informativeText = String(localized: "dialog.closeTab.messageNamed", defaultValue: "This will close \"\(panelName)\".") + } else { + alert.informativeText = String(localized: "dialog.closeTab.message", defaultValue: "This will close the current tab.") + } alert.alertStyle = .warning alert.addButton(withTitle: String(localized: "dialog.closeTab.close", defaultValue: "Close")) alert.addButton(withTitle: String(localized: "dialog.closeTab.cancel", defaultValue: "Cancel"))