From 20899216df0283a9e29f1e45badeb3a8714e6b99 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 18 Dec 2024 07:26:26 +0100 Subject: [PATCH] dialogs - add `Cmd+D` handling (fix #71430) (#236434) --- src/vs/base/browser/ui/dialog/dialog.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/vs/base/browser/ui/dialog/dialog.ts b/src/vs/base/browser/ui/dialog/dialog.ts index 5fcebbd34c6..2ed8d24fadf 100644 --- a/src/vs/base/browser/ui/dialog/dialog.ts +++ b/src/vs/base/browser/ui/dialog/dialog.ts @@ -275,6 +275,22 @@ export class Dialog extends Disposable { return; // leave default handling } + // Cmd+D (trigger the "no"/"do not save"-button) (macOS only) + if (isMacintosh && evt.equals(KeyMod.CtrlCmd | KeyCode.KeyD)) { + EventHelper.stop(e); + + const noButton = buttonMap.find(button => button.index === 1 && button.index !== this.options.cancelId); + if (noButton) { + resolve({ + button: noButton.index, + checkboxChecked: this.checkbox ? this.checkbox.checked : undefined, + values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined + }); + } + + return; // leave default handling + } + if (evt.equals(KeyCode.Space)) { return; // leave default handling }