1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-28 08:13:17 +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 var appState = pair.state
appState.openQuickly.open = false appState.openQuickly.open = false
appState.openQuickly.cwd = FileUtils.userHomeUrl
switch pair.action { switch pair.action {
@ -47,16 +46,10 @@ class OpenQuicklyReducer: ReducerType {
case .openQuickly: case .openQuickly:
var appState = pair.state var appState = pair.state
guard let uuid = appState.currentMainWindowUuid else { guard let uuid = appState.currentMainWindowUuid,
return pair appState.mainWindows[uuid]?.cwd != nil else { return pair }
}
guard let cwd = appState.mainWindows[uuid]?.cwd else {
return pair
}
appState.openQuickly.open = true appState.openQuickly.open = true
appState.openQuickly.cwd = cwd
return (appState, pair.action, true) return (appState, pair.action, true)

View File

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

View File

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