We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2a1578 commit 5ca9e8dCopy full SHA for 5ca9e8d
1 file changed
Core/Sources/Service/Workspace.swift
@@ -162,7 +162,20 @@ final class Workspace {
162
163
let projectURL = try await Environment.fetchCurrentProjectRootURL(fileURL)
164
let workspaceURL = projectURL ?? fileURL
165
- let workspace = workspaces[workspaceURL] ?? Workspace(projectRootURL: workspaceURL)
+
166
+ let workspace = {
167
+ if let existed = workspaces[workspaceURL] {
168
+ return existed
169
+ }
170
+ // Reuse existed workspace if possible
171
+ for (_, workspace) in workspaces {
172
+ if fileURL.path.hasPrefix(workspace.projectRootURL.path) {
173
+ return workspace
174
175
176
+ return Workspace(projectRootURL: workspaceURL)
177
+ }()
178
179
let filespace = workspace.createFilespaceIfNeeded(fileURL: fileURL)
180
workspaces[workspaceURL] = workspace
181
workspace.refreshUpdateTime()
0 commit comments