Merge pull request #1845 from mvanhorn/osc/1603-close-tab-show-name

feat(dialog): show tab name in close tab confirmation
This commit is contained in:
Lawrence Chen 2026-03-21 03:16:36 -07:00 committed by GitHub
commit 65b2ba7597
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 1 deletions

View file

@ -29616,6 +29616,23 @@
}
}
},
"dialog.closeTab.messageNamed": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "This will close \"%@\"."
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "「%@」を閉じます。"
}
}
}
},
"dialog.closeTab.title": {
"extractionState": "manual",
"localizations": {

View file

@ -9230,8 +9230,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"))