microsoft / microsoft/vscode

macOS 15: Space in the save-changes dialog hits Cancel instead of Don't Save

Open
#332,498 0 comments 0 reactions 1 assignee Claimed by @deepak1556 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

On macOS 15, Space in the "Do you want to save the changes you made to X?" dialog now activates **Cancel** instead of **Don't Save**.

The muscle memory this breaks is Enter = save, Space = discard, Esc = go back — three one-key answers to a three-way question, none of which needs the mouse. Space is the one that silently changed meaning: the same keystroke that used to discard the file now dismisses the dialog and leaves the editor open. It fails quietly, so you find out by pressing it twice and wondering why the tab is still there.

### Cause

`massageMessageBoxOptions` used to move the cancel button to index 1 on every macOS. NSAlert lays out `[0]` on the right, `[1]` on the left and the rest in between, so the buttons rendered horizontally with the focus ring on "Don't Save":

```
[ Cancel ][ Don't Save ][ Save ]
Esc Space Enter
```

https://github.com/microsoft/vscode/commit/a064657382897f532319984f13ffbb68743a45fe ("Remove legacy reordering for native dialogs on macOS", #327337) gates that reordering behind Darwin < 24, so macOS 15+ now gets the array unchanged: `[Save, Don't Save, Cancel]`. Three equal buttons make NSAlert stack them vertically, and the focus ring lands on the last one — Cancel.

Enter and Esc survive because Electron assigns those key equivalents explicitly (`setKeyEquivalent:@"\r"` on `default_id`, `@"\e"` on `cancel_id` in `shell/browser/ui/message_box_mac.mm`). "Don't Save" has never had a key equivalent — it only ever inherited the ring from its position, which is why removing the reordering removed the shortcut with it.

### Steps to Reproduce

1. On macOS 15 or later, edit a file so the tab is dirty.
2. `Cmd+W`.
3. Press Space.

Expected: changes discarded, tab closes (behaviour before the linked commit).
Actual: dialog is cancelled, tab stays open with the changes.

### Notes

The vertical button stack is itself a symptom: a native macOS save alert is horizontal, with Cancel on the left and the destructive alternative in the middle. Reverting to that layout restores the ring for free. Giving "Don't Save" an explicit key equivalent would be an independent fix, and arguably the more durable one, since it would not depend on AppKit's key-view loop at all.

Verified locally by raising the Darwin bound in `out/main.js`: the horizontal layout and Space returned.

---

- VS Code 1.134.0 (Electron 42.8.1)
- macOS 15.1 (Darwin 24.1.0)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.