     let visibleRect = self.enclosingScrollView?.contentView.visibleRect
 
     let expandedItems = self.expandedItems
+
+    if item == nil {
+      self.fileItems.removeAll()
+    } else {
+      guard let fileItem = item as? FileItem else {
+        preconditionFailure("Should not happen")
+      }
+
+      self.fileItems.remove(fileItem)
+      if fileItem.dir {
+        self.fileItems
+          .filter { fileItem.url.parent(ofUrl: $0.url) }
+          .forEach { self.fileItems.remove($0) }
+      }
+    }
+
     super.reloadItem(item, reloadChildren: reloadChildren)
 
     self.restore(expandedItems: expandedItems)

  fileprivate let flow: EmbeddableComponent
  fileprivate let fileItemService: FileItemService

  fileprivate var expandedItems = Set<FileItem>()

  required init?(coder: NSCoder) {


  func outlineView(_: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
    if item == nil {
      let result = self.fileItemService.fileItemWithChildren(for: self.cwd)!.children.filter { !$0.hidden }[index]
      self.fileItems.insert(result)

      return result
    }

    guard let fileItem = item as? FileItem else {
      preconditionFailure("Should not happen")
    }

    let result = self.fileItemService.fileItemWithChildren(for: fileItem.url)!.children.filter { !$0.hidden }[index]
    self.fileItems.insert(result)

    return result
  }

  func outlineView(_: NSOutlineView, isItemExpandable item: Any) ->  Bool {
