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

Add uses vcs ignore field

This commit is contained in:
Tae Won Ha 2020-01-18 15:23:22 +01:00
parent eafdcf63b0
commit 50221c4d38
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 21 additions and 18 deletions

View File

@ -17,7 +17,6 @@ class OpenQuicklyReducer: ReducerType {
var appState = pair.state
appState.openQuickly.open = false
appState.openQuickly.cwd = FileUtils.userHomeUrl
switch pair.action {
@ -47,16 +46,10 @@ class OpenQuicklyReducer: ReducerType {
case .openQuickly:
var appState = pair.state
guard let uuid = appState.currentMainWindowUuid else {
return pair
}
guard let cwd = appState.mainWindows[uuid]?.cwd else {
return pair
}
guard let uuid = appState.currentMainWindowUuid,
appState.mainWindows[uuid]?.cwd != nil else { return pair }
appState.openQuickly.open = true
appState.openQuickly.cwd = cwd
return (appState, pair.action, true)

View File

@ -47,8 +47,8 @@ class OpenQuicklyWindow: NSObject,
private let emit: (Action) -> Void
private let disposeBag = DisposeBag()
private(set) var cwd = FileUtils.userHomeUrl
private var cwdPathCompsCount = 0
private var usesVcsIgnores = true
private var scanToken = Token()
private var fileServicesPerRootUrl: [URL: FileService] = [:]
@ -78,6 +78,13 @@ class OpenQuicklyWindow: NSObject,
private func subscription(_ state: StateType) {
self.updateRootUrls(state: state)
guard let curWinUuid = state.currentMainWindowUuid,
let curWinState = state.mainWindows[curWinUuid] else {
self.windowController.close()
return
}
Swift.print(curWinState.usesVcsIgnores)
guard state.openQuickly.open else {
self.windowController.close()
@ -89,23 +96,25 @@ class OpenQuicklyWindow: NSObject,
return
}
self.cwd = state.openQuickly.cwd
self.cwdPathCompsCount = self.cwd.pathComponents.count
self.cwdControl.url = self.cwd
let cwd = curWinState.cwd
self.cwdPathCompsCount = cwd.pathComponents.count
self.cwdControl.url = cwd
self.searchField.rx
.text.orEmpty
.throttle(.milliseconds(1 * 500), latest: true, scheduler: MainScheduler.instance)
.distinctUntilChanged()
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [weak self] pattern in self?.scanAndScore(pattern) })
.subscribe(onNext: { [weak self] pattern in
guard let fileService = self?.fileServicesPerRootUrl[cwd] else { return }
self?.scanAndScore(pattern, with: fileService)
})
.disposed(by: self.disposeBag)
self.windowController.showWindow(self)
}
private func scanAndScore(_ pattern: String) {
guard let fileService = self.fileServicesPerRootUrl[self.cwd] else { return }
private func scanAndScore(_ pattern: String, with fileService: FileService) {
fileService.stopScanScore()
guard pattern.count >= 2 else {
@ -135,7 +144,7 @@ class OpenQuicklyWindow: NSObject,
private func updateRootUrls(state: AppState) {
let urlsToMonitor = Set(state.mainWindows.map { $1.cwd })
let currentUrls = Set(self.fileServicesPerRootUrl.map { url, _ in url })
let currentUrls = Set(self.fileServicesPerRootUrl.map { url, _ in url })
let newUrls = urlsToMonitor.subtracting(currentUrls)
let obsoleteUrls = currentUrls.subtracting(urlsToMonitor)

View File

@ -80,7 +80,6 @@ extension OpenQuicklyWindow {
case ignorePatterns = "ignore-patterns"
}
var cwd = FileUtils.userHomeUrl
var ignorePatterns = State.defaultIgnorePatterns
var ignoreToken = Token()
@ -282,6 +281,8 @@ extension MainWindow {
var cliPipePath: String?
var envDict: [String: String]?
var usesVcsIgnores = true
var isLeftOptionMeta = false
var isRightOptionMeta = false