Skip to content

Commit 3153431

Browse files
committed
fix(server): retain configured projects of open files directly (issue #7)
getOrphanConfiguredProjects retains an open file's configured project by probing tryFindDefaultConfiguredProjectAndLoadAncestorsForOpen- ScriptInfo. The fork assigns open files to configured projects through its own path for extensions stock doesn't support there (e.g. .vue), so the probe returns NONE and cleanupProjectsAndScriptInfos removed a live configured project out from under its open file — 0.2s after a second project's file opened, the first project vanished and the .vue was orphaned (containingProjects=[]). Retain configured projects straight from each open scriptInfo's containingProjects before running the probe. This is a superset of what the probe retains, so stock-observable behavior is unchanged; stock removes the same project in the same scenario because stock never assigns .vue to it in the first place.
1 parent d7bc16b commit 3153431

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

‎patches/typescript/0001-tsgo-hooks.patch‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ index 04ca4db0fd..e1ed32c9eb 100644
379379
return {
380380
type: UpToDateStatusType.OutOfDateBuildInfoWithErrors,
381381
diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts
382-
index aa578c7ed0..b8fda38051 100644
382+
index aa578c7ed0..6cb2fce32a 100644
383383
--- a/src/server/editorServices.ts
384384
+++ b/src/server/editorServices.ts
385385
@@ -2191,7 +2191,47 @@ export class ProjectService {
@@ -454,6 +454,24 @@ index aa578c7ed0..b8fda38051 100644
454454
}
455455

456456
/** @internal */
457+
@@ -4920,6 +4944,17 @@ export class ProjectService {
458+
const info = this.getScriptInfoForPath(path)!;
459+
// Part of external project
460+
if (find(info.containingProjects, isExternalProject)) return;
461+
+ // TNB (issue #7): the fork assigns open files to configured projects
462+
+ // through its own path for extensions stock doesn't support in
463+
+ // configured projects (e.g. .vue) — the default-project probe below
464+
+ // returns NONE for them, so a live project would be orphan-cleaned
465+
+ // out from under its open files. Retain directly from
466+
+ // containingProjects first; a superset of the probe's retainment,
467+
+ // so stock-observable behavior is unchanged.
468+
+ for (const containingProject of info.containingProjects) {
469+
+ if (isConfiguredProject(containingProject)) retainConfiguredProject(containingProject);
470+
+ }
471+
+ if (!toRemoveConfiguredProjects.size) return toRemoveConfiguredProjects;
472+
// We want to retain the projects for open file if they are pending updates so deferredClosed projects are ok
473+
const result = this.tryFindDefaultConfiguredProjectAndLoadAncestorsForOpenScriptInfo(
474+
info,
457475
diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts
458476
index 6034c9dfc3..0c9a6178db 100644
459477
--- a/src/services/codefixes/importFixes.ts

0 commit comments

Comments
 (0)