mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-26 07:13:24 +03:00
GH-218 Ask user to confirm to discard unsaved buffers
This commit is contained in:
parent
89fdab1566
commit
6278ee24c5
@ -30,7 +30,24 @@ class MainWindowController: NSWindowController, NSWindowDelegate, NeoVimViewDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
func windowShouldClose(sender: AnyObject) -> Bool {
|
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
|
// MARK: - NeoVimViewDelegate
|
||||||
|
Loading…
Reference in New Issue
Block a user