1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 23:02:35 +03:00

GH-218 Ask user to confirm to discard unsaved buffers

This commit is contained in:
Tae Won Ha 2016-07-18 20:16:56 +02:00
parent 89fdab1566
commit 6278ee24c5
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -30,7 +30,24 @@ class MainWindowController: NSWindowController, NSWindowDelegate, NeoVimViewDele
}
func windowShouldClose(sender: AnyObject) -> Bool {
return !self.neoVimView.hasDirtyDocs()
let hasDirtyDocs = self.neoVimView.hasDirtyDocs()
if !hasDirtyDocs {
return true
}
let alert = NSAlert()
alert.addButtonWithTitle("Cancel")
alert.addButtonWithTitle("Discard and Close")
alert.messageText = "There are unsaved buffers!"
alert.alertStyle = .WarningAlertStyle
alert.beginSheetModalForWindow(self.window!) { response in
if response == NSAlertSecondButtonReturn {
self.close()
}
}
return false
}
// MARK: - NeoVimViewDelegate