     }
 
     DispatchQueue.main.async {
-      let result = Array(sorted[0...min(self.maxResultCount, sorted.count - 1)])
+      let result = Array(sorted[0...min(maxResultCount, sorted.count - 1)])
       self.openQuickly.reloadFileView(withScoredItems: result)
     }
   }
+
+  fileprivate let pattern: String
+  fileprivate let flatFileItems: [FileItem]
+  fileprivate let cwd: URL
+
+  fileprivate unowned let openQuickly: OpenQuicklyWindow
 }
+
+fileprivate let chunkSize = 100
+fileprivate let maxResultCount = 500


    let sorted: [ScoredFileItem]
    if pattern.characters.count == 0 {
      let truncatedItems = self.flatFileItems[0...min(self.maxResultCount, self.flatFileItems.count - 1)]
      sorted = truncatedItems.map { ScoredFileItem(score: 0, url: $0.url) }
    } else {
      DispatchQueue.main.async { self.openQuickly.startProgress() }
      defer { DispatchQueue.main.async { self.openQuickly.endProgress() } }

      let count = self.flatFileItems.count
      let chunksCount = Int(ceil(Float(count) / Float(self.chunkSize)))
      let useFullPath = pattern.contains("/")
      let cwdPath = self.cwd.path + "/"



class OpenQuicklyFilterOperation: Operation {

  init(forOpenQuickly openQuickly: OpenQuicklyWindow) {
    self.openQuickly = openQuickly
    self.pattern = openQuickly.pattern
    self.cwd = openQuickly.cwd
    self.flatFileItems = openQuickly.flatFileItems

    super.init()
