mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 03:25:03 +03:00
GH-423 Use transient fields in state for cwd and current buffer to set
This commit is contained in:
parent
91fac3868e
commit
786ac2a87e
@ -91,7 +91,7 @@ class Context {
|
|||||||
.disposed(by: self.disposeBag)
|
.disposed(by: self.disposeBag)
|
||||||
|
|
||||||
#if DEBUG
|
#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)
|
// stateSource.debug().subscribe().disposed(by: self.disposeBag)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -122,6 +122,8 @@ class Context {
|
|||||||
|
|
||||||
fileprivate func cleanUpAppState() {
|
fileprivate func cleanUpAppState() {
|
||||||
self.appState.mainWindows.keys.forEach { uuid in
|
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]?.viewToBeFocused = nil
|
||||||
self.appState.mainWindows[uuid]?.urlsToOpen.removeAll()
|
self.appState.mainWindows[uuid]?.urlsToOpen.removeAll()
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class FileBrowserReducer {
|
|||||||
state.viewToBeFocused = .neoVimView
|
state.viewToBeFocused = .neoVimView
|
||||||
|
|
||||||
case let .setAsWorkingDirectory(url):
|
case let .setAsWorkingDirectory(url):
|
||||||
state.cwd = url
|
state.cwdToSet = url
|
||||||
|
|
||||||
case let .setShowHidden(show):
|
case let .setShowHidden(show):
|
||||||
state.fileBrowserShowHidden = show
|
state.fileBrowserShowHidden = show
|
||||||
|
@ -187,9 +187,9 @@ class MainWindow: NSObject,
|
|||||||
|
|
||||||
self.windowController.setDocumentEdited(state.isDirty)
|
self.windowController.setDocumentEdited(state.isDirty)
|
||||||
|
|
||||||
// if self.neoVimView.cwd != state.cwd {
|
if let cwd = state.cwdToSet {
|
||||||
// self.neoVimView.cwd = state.cwd
|
self.neoVimView.cwd = cwd
|
||||||
// }
|
}
|
||||||
|
|
||||||
if state.previewTool.isReverseSearchAutomatically
|
if state.previewTool.isReverseSearchAutomatically
|
||||||
&& state.preview.previewPosition.hasDifferentMark(as: self.previewPosition)
|
&& state.preview.previewPosition.hasDifferentMark(as: self.previewPosition)
|
||||||
@ -203,11 +203,8 @@ class MainWindow: NSObject,
|
|||||||
|
|
||||||
self.open(urls: state.urlsToOpen)
|
self.open(urls: state.urlsToOpen)
|
||||||
|
|
||||||
if self.currentBuffer != state.currentBuffer {
|
if let currentBuffer = state.currentBufferToSet {
|
||||||
self.currentBuffer = state.currentBuffer
|
self.neoVimView.select(buffer: currentBuffer)
|
||||||
if let currentBuffer = self.currentBuffer {
|
|
||||||
self.neoVimView.select(buffer: currentBuffer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.defaultFont != state.appearance.font
|
if self.defaultFont != state.appearance.font
|
||||||
@ -248,7 +245,9 @@ class MainWindow: NSObject,
|
|||||||
fileprivate var currentBuffer: NeoVimBuffer?
|
fileprivate var currentBuffer: NeoVimBuffer?
|
||||||
|
|
||||||
fileprivate let windowController: NSWindowController
|
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 defaultFont: NSFont
|
||||||
fileprivate var linespacing: CGFloat
|
fileprivate var linespacing: CGFloat
|
||||||
@ -444,9 +443,10 @@ extension MainWindow {
|
|||||||
let urls = panel.urls
|
let urls = panel.urls
|
||||||
if self.neoVimView.allBuffers().count == 1 {
|
if self.neoVimView.allBuffers().count == 1 {
|
||||||
let isTransient = self.neoVimView.allBuffers().first?.isTransient ?? false
|
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)
|
self.neoVimView.open(urls: urls)
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class OpenedFileListReducer {
|
|||||||
switch pair.action {
|
switch pair.action {
|
||||||
|
|
||||||
case let .open(buffer):
|
case let .open(buffer):
|
||||||
state.currentBuffer = buffer
|
state.currentBufferToSet = buffer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +223,8 @@ extension MainWindow {
|
|||||||
|
|
||||||
// to be cleaned
|
// to be cleaned
|
||||||
var urlsToOpen = [URL: OpenMode]()
|
var urlsToOpen = [URL: OpenMode]()
|
||||||
|
var currentBufferToSet: NeoVimBuffer?
|
||||||
|
var cwdToSet: URL?
|
||||||
var viewToBeFocused: FocusableView? = FocusableView.neoVimView
|
var viewToBeFocused: FocusableView? = FocusableView.neoVimView
|
||||||
|
|
||||||
init(isAllToolsVisible: Bool, isToolButtonsVisible: Bool) {
|
init(isAllToolsVisible: Bool, isToolButtonsVisible: Bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user