fix(cmux): focus close confirmation actions
This commit is contained in:
parent
9bfa3b9143
commit
7f40e0097b
2 changed files with 15 additions and 7 deletions
|
|
@ -1587,6 +1587,7 @@ class TabManager: ObservableObject {
|
|||
if let confirmCloseHandler {
|
||||
return confirmCloseHandler(title, message, acceptCmdD)
|
||||
}
|
||||
_ = acceptCmdD
|
||||
|
||||
let alert = NSAlert()
|
||||
alert.messageText = title
|
||||
|
|
@ -1596,16 +1597,17 @@ class TabManager: ObservableObject {
|
|||
alert.addButton(withTitle: String(localized: "common.cancel", defaultValue: "Cancel"))
|
||||
|
||||
if let closeButton = alert.buttons.first {
|
||||
// Keep Return/Enter bound to the primary destructive action for all close prompts.
|
||||
closeButton.keyEquivalent = "\r"
|
||||
closeButton.keyEquivalentModifierMask = []
|
||||
alert.window.defaultButtonCell = closeButton.cell as? NSButtonCell
|
||||
alert.window.initialFirstResponder = closeButton
|
||||
}
|
||||
if let cancelButton = alert.buttons.dropFirst().first {
|
||||
cancelButton.keyEquivalent = "\u{1b}"
|
||||
}
|
||||
|
||||
// macOS convention: Cmd+D = confirm destructive close (e.g. "Don't Save").
|
||||
// We only opt into this for the "close last workspace => close window" path to avoid
|
||||
// conflicting with app-level Cmd+D (split right) during normal usage.
|
||||
if acceptCmdD, let closeButton = alert.buttons.first {
|
||||
closeButton.keyEquivalent = "d"
|
||||
closeButton.keyEquivalentModifierMask = [.command]
|
||||
if NSApp.activationPolicy() == .regular {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
|
||||
return alert.runModal() == .alertFirstButtonReturn
|
||||
|
|
|
|||
|
|
@ -4148,7 +4148,13 @@ extension Workspace: BonsplitDelegate {
|
|||
alert.addButton(withTitle: String(localized: "common.cancel", defaultValue: "Cancel"))
|
||||
|
||||
if let closeButton = alert.buttons.first {
|
||||
closeButton.keyEquivalent = "\r"
|
||||
closeButton.keyEquivalentModifierMask = []
|
||||
alert.window.defaultButtonCell = closeButton.cell as? NSButtonCell
|
||||
alert.window.initialFirstResponder = closeButton
|
||||
}
|
||||
if let cancelButton = alert.buttons.dropFirst().first {
|
||||
cancelButton.keyEquivalent = "\u{1b}"
|
||||
}
|
||||
|
||||
// Prefer a sheet if we can find a window, otherwise fall back to modal.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue