diff --git a/Sources/SaplingApp/SaplingApp.swift b/Sources/SaplingApp/SaplingApp.swift index 06cc216..daa625d 100644 --- a/Sources/SaplingApp/SaplingApp.swift +++ b/Sources/SaplingApp/SaplingApp.swift @@ -164,19 +164,25 @@ private final class SaplingAppModel: ObservableObject { guard let url = item.containerURL?.standardizedFileURL else { return } guard workspaceChildren[url] == nil, !loadingTreeItemURLs.contains(url) else { return } - loadingTreeItemURLs.insert(url) + var loadingURLs = loadingTreeItemURLs + loadingURLs.insert(url) + loadingTreeItemURLs = loadingURLs let workspaceManager = self.workspaceManager Task { do { let children = try await Task.detached { try await workspaceManager.loadItems(in: url) }.value - workspaceChildren[url] = children + var loadedChildren = workspaceChildren + loadedChildren[url] = children + workspaceChildren = loadedChildren } catch { editorErrorMessage = "Unable to load \(item.displayName): \(error.localizedDescription)" logger.error("Failed to load workspace tree item: \(error)", category: .workspace) } - loadingTreeItemURLs.remove(url) + var loadingURLs = loadingTreeItemURLs + loadingURLs.remove(url) + loadingTreeItemURLs = loadingURLs } }