1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 23:36:08 +03:00
This commit is contained in:
Tae Won Ha 2020-01-17 20:42:13 +01:00
parent e3374e0587
commit 354aa7e5cb
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -56,10 +56,25 @@ class OpenQuicklyWindow: NSObject,
self.cwd = state.openQuickly.cwd
self.cwdPathCompsCount = self.cwd.pathComponents.count
self.cwdControl.url = self.cwd
self.currentFileService = self.fileServicesPerRootUrl[self.cwd]
self.searchStream
.observeOn(MainScheduler.instance)
.subscribe(onNext: { pattern in
self.pattern = pattern
guard pattern.count >= 2 else {return }
self.currentFileService?.stopScanScore()
self.scanToken = Token()
let localToken = self.scanToken
self.fileViewItems.removeAll()
self.currentFileService?.scanScore(for: pattern) { scoredUrls in
DispatchQueue.main.async {
guard localToken == self.scanToken else { return }
self.fileViewItems.append(contentsOf: scoredUrls)
}
}
})
.disposed(by: self.disposeBag)
@ -81,13 +96,15 @@ class OpenQuicklyWindow: NSObject,
private(set) var cwd = FileUtils.userHomeUrl
private var cwdPathCompsCount = 0
private var currentFileService: FileService?
private var scanToken = Token()
private var fileServicesPerRootUrl: [URL: FileService] = [:]
private var rootUrls: Set<URL> { Set(self.fileServicesPerRootUrl.map { url, _ in url }) }
// FIXME: migrate to State later...
private(set) var pattern = ""
@objc private(set) var fileViewItems = [ScoredUrl]()
@objc dynamic private(set) var fileViewItems = [ScoredUrl]()
private var count = 0
private let fileViewItemsController = NSArrayController()