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

GH-423 Use transient fields in state for cwd and current buffer to set

This commit is contained in:
Tae Won Ha 2017-06-09 23:16:06 +02:00
parent 91fac3868e
commit 786ac2a87e
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
5 changed files with 19 additions and 15 deletions

View File

@ -91,7 +91,7 @@ class Context {
.disposed(by: self.disposeBag)
#if DEBUG
// actionSource.debug().subscribe().disposed(by: self.disposeBag)
// self.actionEmitter.observable.debug().subscribe().disposed(by: self.disposeBag)
// stateSource.debug().subscribe().disposed(by: self.disposeBag)
#endif
}
@ -122,6 +122,8 @@ class Context {
fileprivate func cleanUpAppState() {
self.appState.mainWindows.keys.forEach { uuid in
self.appState.mainWindows[uuid]?.cwdToSet = nil
self.appState.mainWindows[uuid]?.currentBufferToSet = nil
self.appState.mainWindows[uuid]?.viewToBeFocused = nil
self.appState.mainWindows[uuid]?.urlsToOpen.removeAll()
}

View File

@ -19,7 +19,7 @@ class FileBrowserReducer {
state.viewToBeFocused = .neoVimView
case let .setAsWorkingDirectory(url):
state.cwd = url
state.cwdToSet = url
case let .setShowHidden(show):
state.fileBrowserShowHidden = show

View File

@ -187,9 +187,9 @@ class MainWindow: NSObject,
self.windowController.setDocumentEdited(state.isDirty)
// if self.neoVimView.cwd != state.cwd {
// self.neoVimView.cwd = state.cwd
// }
if let cwd = state.cwdToSet {
self.neoVimView.cwd = cwd
}
if state.previewTool.isReverseSearchAutomatically
&& state.preview.previewPosition.hasDifferentMark(as: self.previewPosition)
@ -203,11 +203,8 @@ class MainWindow: NSObject,
self.open(urls: state.urlsToOpen)
if self.currentBuffer != state.currentBuffer {
self.currentBuffer = state.currentBuffer
if let currentBuffer = self.currentBuffer {
self.neoVimView.select(buffer: currentBuffer)
}
if let currentBuffer = state.currentBufferToSet {
self.neoVimView.select(buffer: currentBuffer)
}
if self.defaultFont != state.appearance.font
@ -248,7 +245,9 @@ class MainWindow: NSObject,
fileprivate var currentBuffer: NeoVimBuffer?
fileprivate let windowController: NSWindowController
fileprivate var window: NSWindow { return self.windowController.window! }
fileprivate var window: NSWindow {
return self.windowController.window!
}
fileprivate var defaultFont: NSFont
fileprivate var linespacing: CGFloat
@ -444,9 +443,10 @@ extension MainWindow {
let urls = panel.urls
if self.neoVimView.allBuffers().count == 1 {
let isTransient = self.neoVimView.allBuffers().first?.isTransient ?? false
// if isTransient {
// self.neoVimView.cwd = FileUtils.commonParent(of: urls)
// }
if isTransient {
self.neoVimView.cwd = FileUtils.commonParent(of: urls)
}
}
self.neoVimView.open(urls: urls)
}

View File

@ -15,7 +15,7 @@ class OpenedFileListReducer {
switch pair.action {
case let .open(buffer):
state.currentBuffer = buffer
state.currentBufferToSet = buffer
}

View File

@ -223,6 +223,8 @@ extension MainWindow {
// to be cleaned
var urlsToOpen = [URL: OpenMode]()
var currentBufferToSet: NeoVimBuffer?
var cwdToSet: URL?
var viewToBeFocused: FocusableView? = FocusableView.neoVimView
init(isAllToolsVisible: Bool, isToolButtonsVisible: Bool) {