From 911e860d36e23395810a517245a43db24390f329 Mon Sep 17 00:00:00 2001 From: Neal Clark Date: Thu, 5 Oct 2017 17:18:47 -0700 Subject: [PATCH] =?UTF-8?q?Close=20the=20=E2=80=9CDiscard=20and=20Quit?= =?UTF-8?q?=E2=80=9D=20menu=20with=20=E2=8C=98-D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow quitting the application with an unsaved buffer via the keyboard. macvim makes the “Quit” button default. vimr makes the “Cancel” button default, leaving no way to “Discard and Quit” without using the mouse (as far as I can tell). ⌘-D uses the convention of ⌘ + first letter of the button text --- VimR/AppDelegate.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/VimR/AppDelegate.swift b/VimR/AppDelegate.swift index 3f52ea5e..7c20a28e 100644 --- a/VimR/AppDelegate.swift +++ b/VimR/AppDelegate.swift @@ -137,9 +137,11 @@ extension AppDelegate { if self.hasDirtyWindows && self.hasMainWindows { let alert = NSAlert() alert.addButton(withTitle: "Cancel") - alert.addButton(withTitle: "Discard and Quit") + let discardAndQuitButton = alert.addButton(withTitle: "Discard and Quit") alert.messageText = "There are windows with unsaved buffers!" alert.alertStyle = .warning + discardAndQuitButton.keyEquivalentModifierMask = NSCommandKeyMask + discardAndQuitButton.keyEquivalent = "d" if alert.runModal() == NSAlertSecondButtonReturn { self.uiRoot.prepareQuit()