1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-27 14:14:19 +03:00

Adapt to sync neovim stop handling

This commit is contained in:
Tae Won Ha 2017-06-11 16:28:25 +02:00
parent 2d64198e5c
commit 8241d596fd
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
5 changed files with 20 additions and 38 deletions

View File

@ -28,10 +28,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
case openInKeyWindow(urls: [URL], cwd: URL)
case preferences
case cancelQuit
case quitWithoutSaving
case quit
}
@IBOutlet var debugMenu: NSMenuItem?
@ -157,18 +153,16 @@ extension AppDelegate {
alert.alertStyle = .warning
if alert.runModal() == NSAlertSecondButtonReturn {
self.emit(.quitWithoutSaving)
} else {
self.emit(.cancelQuit)
self.uiRoot.prepareQuit()
return .terminateNow
}
return .terminateCancel
}
if self.uiRoot.hasMainWindows {
self.emit(.quit)
return .terminateCancel
self.uiRoot.prepareQuit()
return .terminateNow
}
// There are no open main window, then just quit.

View File

@ -35,13 +35,6 @@ class AppDelegateReducer {
case .preferences:
state.preferencesOpen = Marked(true)
case .cancelQuit:
state.quitWhenNoMainWindow = false
case .quitWithoutSaving, .quit:
state.mainWindows.keys.forEach { state.mainWindows[$0]?.close = true }
state.quitWhenNoMainWindow = true
}
return StateActionPair(state: state, action: pair.action)

View File

@ -175,12 +175,6 @@ class MainWindow: NSObject,
return
}
if state.close && !self.isClosing {
self.closeAllNeoVimWindowsWithoutSaving()
self.isClosing = true
return
}
if state.viewToBeFocused != nil, case .neoVimView = state.viewToBeFocused! {
self.window.makeFirstResponder(self.neoVimView)
}
@ -216,10 +210,11 @@ class MainWindow: NSObject,
self.updateNeoVimAppearance()
}
},
}/*,
onCompleted: {
self.windowController.close()
})
NSLog("Completed!!!!")
// self.windowController.close()
}*/)
.disposed(by: self.disposeBag)
self.updateNeoVimAppearance()
@ -234,6 +229,12 @@ class MainWindow: NSObject,
self.windowController.showWindow(self)
}
// The following should only be used when Cmd-Q'ing
func quitNeoVimWithoutSaving() {
self.isClosing = true
self.neoVimView.quitNeoVimWithoutSaving()
}
fileprivate let emit: (UuidAction<Action>) -> Void
fileprivate let disposeBag = DisposeBag()
@ -275,10 +276,6 @@ class MainWindow: NSObject,
fileprivate var isClosing = false
fileprivate func closeAllNeoVimWindowsWithoutSaving() {
self.neoVimView.quitNeoVimWithoutSaving()
}
fileprivate func updateNeoVimAppearance() {
self.neoVimView.font = self.defaultFont
self.neoVimView.linespacing = self.linespacing
@ -331,6 +328,7 @@ extension MainWindow {
func neoVimStopped() {
self.isClosing = true
self.windowController.close()
self.emit(self.uuidAction(for: .close))
}

View File

@ -21,7 +21,6 @@ struct AppState: SerializableState {
var currentMainWindowUuid: String?
var mainWindows: [String: MainWindow.State] = [:]
var quitWhenNoMainWindow = false
var openQuickly = OpenQuicklyWindow.State.default
@ -218,9 +217,6 @@ extension MainWindow {
var appearance = AppearanceState.default
var useInteractiveZsh = false
// transient^2
var close = false
// to be cleaned
var urlsToOpen = [URL: OpenMode]()
var currentBufferToSet: NeoVimBuffer?

View File

@ -35,14 +35,15 @@ class UiRoot: UiComponent {
self.mainWindows.keys
.filter { !uuidsInState.contains($0) }
.forEach(self.removeMainWindow)
if state.quitWhenNoMainWindow && self.mainWindows.isEmpty {
NSApp.terminate(self)
}
})
.disposed(by: self.disposeBag)
}
// The following should only be used when Cmd-Q'ing
func prepareQuit() {
self.mainWindows.values.forEach { $0.quitNeoVimWithoutSaving() }
}
fileprivate let source: Observable<AppState>
fileprivate let emitter: ActionEmitter
fileprivate let disposeBag = DisposeBag()