1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 00:34:26 +03:00

GH-325 Refactor slightly

This commit is contained in:
Tae Won Ha 2017-08-20 14:53:09 +02:00
parent 3237dd23f7
commit ab21bb767e
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 6 additions and 12 deletions

View File

@ -132,6 +132,8 @@ extension AppDelegate {
}
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplicationTerminateReply {
self.stateContext.savePrefs()
if self.hasDirtyWindows && self.hasMainWindows {
let alert = NSAlert()
alert.addButton(withTitle: "Cancel")
@ -141,7 +143,6 @@ extension AppDelegate {
if alert.runModal() == NSAlertSecondButtonReturn {
self.uiRoot.prepareQuit()
self.stateContext.savePrefs()
return .terminateNow
}
@ -150,12 +151,10 @@ extension AppDelegate {
if self.hasMainWindows {
self.uiRoot.prepareQuit()
self.stateContext.savePrefs()
return .terminateNow
}
// There are no open main window, then just quit.
self.stateContext.savePrefs()
return .terminateNow
}
@ -314,4 +313,4 @@ fileprivate let filePrefix = "file="
fileprivate let cwdPrefix = "cwd="
fileprivate let nvimArgsPrefix = "nvim-args="
fileprivate let pipePathPrefix = "pipe-path="
fileprivate let waitPrefix = "wait="
fileprivate let waitPrefix = "wait="

View File

@ -68,14 +68,9 @@ class AppDelegateReducer {
mainWindow.nvimArgs = nvimArgs
mainWindow.cliPipePath = cliPipePath
mainWindow.urlsToOpen = urls.toDict { _ in MainWindow.OpenMode.default }
if state.mainWindows.isEmpty {
return mainWindow
}
mainWindow.frame = self.frame(relativeTo: state.mainWindowTemplate.frame)
mainWindow.frame = state.mainWindows.isEmpty ? state.mainWindowTemplate.frame
: self.frame(relativeTo: state.mainWindowTemplate.frame)
return mainWindow
}

View File

@ -269,7 +269,7 @@ extension MainWindow {
self.useInteractiveZsh = PrefUtils.bool(from: dict, for: Keys.MainWindow.useInteractiveZsh, default: false)
let frameString = PrefUtils.string(from: dict,
for: Keys.MainWindow.frame,
default: NSStringFromRect(CGRect(x: 100, y: 100, width: 600, height: 400)))
default: NSStringFromRect(self.frame))
self.frame = NSRectFromString(frameString)
self.isAllToolsVisible = isAllToolsVisible