File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,20 @@ final class Workspace {
162162
163163 let projectURL = try await Environment . fetchCurrentProjectRootURL ( fileURL)
164164 let workspaceURL = projectURL ?? fileURL
165- let workspace = workspaces [ workspaceURL] ?? Workspace ( projectRootURL: workspaceURL)
165+
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+
166179 let filespace = workspace. createFilespaceIfNeeded ( fileURL: fileURL)
167180 workspaces [ workspaceURL] = workspace
168181 workspace. refreshUpdateTime ( )
You can’t perform that action at this time.
0 commit comments