Skip to content

Commit b031777

Browse files
committed
PR Feedback
1 parent 37b9b70 commit b031777

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ namespace ts.projectSystem {
190190
if (opts.typingsInstaller === undefined) {
191191
opts.typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/ 5, host);
192192
}
193-
193+
194194
if (opts.eventHandler !== undefined) {
195195
opts.canUseEvents = true;
196196
}

src/server/editorServices.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,16 @@ namespace ts.server {
484484

485485
const updatedProjects: Project[] = [];
486486
for (const project of this.inferredProjects) {
487-
if (projectRootPath ?
488-
project.projectRootPath === projectRootPath :
487+
// Only update compiler options in the following cases:
488+
// - Inferred projects without a projectRootPath, if the new options do not apply to
489+
// a workspace root
490+
// - Inferred projects with a projectRootPath, if the new options do not apply to a
491+
// workspace root and there is no more specific set of options for that project's
492+
// root path
493+
// - Inferred projects with a projectRootPath, if the new options apply to that
494+
// project root path.
495+
if (projectRootPath ?
496+
project.projectRootPath === projectRootPath :
489497
!project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) {
490498
project.setCompilerOptions(compilerOptions);
491499
project.compileOnSaveEnabled = compilerOptions.compileOnSave;
@@ -1320,7 +1328,7 @@ namespace ts.server {
13201328
return this.createInferredProject(/*isSingleInferredProject*/ false, projectRootPath);
13211329
}
13221330

1323-
// we don't have an explicit root path, so we should try to find an inferred project
1331+
// we don't have an explicit root path, so we should try to find an inferred project
13241332
// that more closely contains the file.
13251333
let bestMatch: InferredProject;
13261334
for (const project of this.inferredProjects) {
@@ -1342,11 +1350,11 @@ namespace ts.server {
13421350
return undefined;
13431351
}
13441352

1345-
// If `useInferredProjectPerProjectRoot` is not enabled, then there will only be one
1346-
// inferred project for all files. If `useInferredProjectPerProjectRoot` is enabled
1353+
// If `useInferredProjectPerProjectRoot` is not enabled, then there will only be one
1354+
// inferred project for all files. If `useInferredProjectPerProjectRoot` is enabled
13471355
// then we want to put all files that are not opened with a `projectRootPath` into
13481356
// the same inferred project.
1349-
//
1357+
//
13501358
// To avoid the cost of searching through the array and to optimize for the case where
13511359
// `useInferredProjectPerProjectRoot` is not enabled, we will always put the inferred
13521360
// project for non-rooted files at the front of the array.

0 commit comments

Comments
 (0)