Skip to content

Commit

Permalink
Fix file node invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Aug 26, 2024
1 parent 36c83cc commit 8f2735f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions CotEditor/Sources/FileNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,22 @@ extension FileNode {
else { return false }

if fileURL.deletingLastPathComponent() == self.fileURL {
// -> The given fileURL is in this node.
guard !children.map(\.fileURL).contains(fileURL) else { return false }

// just invalidate all children
self._children = nil
return true
// -> The given fileURL is in this node.
if let index = children.firstIndex(where: { $0.fileURL == fileURL }) {
if (try? fileURL.checkResourceIsReachable()) == true {
return false
} else {
// -> The file is deleted.
self._children?.remove(at: index)
return true
}

} else {
// just invalidate all children
self._children = nil
return true
}

} else {
return children.contains { $0.invalidateChildren(at: fileURL) }
Expand Down

0 comments on commit 8f2735f

Please sign in to comment.