Skip to content

Commit 370a596

Browse files
authored
Merge pull request #32847 from microsoft/jsEditPerf
Check cancellation token in function/arrow/class expresisons, Cleanup after open file only if new file is opened in the request
2 parents c8d937e + c52b129 commit 370a596

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/compiler/checker.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -25271,7 +25271,18 @@ namespace ts {
2527125271
}
2527225272

2527325273
function checkExpressionWorker(node: Expression | QualifiedName, checkMode: CheckMode | undefined, forceTuple?: boolean): Type {
25274-
switch (node.kind) {
25274+
const kind = node.kind;
25275+
if (cancellationToken) {
25276+
// Only bother checking on a few construct kinds. We don't want to be excessively
25277+
// hitting the cancellation token on every node we check.
25278+
switch (kind) {
25279+
case SyntaxKind.ClassExpression:
25280+
case SyntaxKind.FunctionExpression:
25281+
case SyntaxKind.ArrowFunction:
25282+
cancellationToken.throwIfCancellationRequested();
25283+
}
25284+
}
25285+
switch (kind) {
2527525286
case SyntaxKind.Identifier:
2527625287
return checkIdentifier(<Identifier>node);
2527725288
case SyntaxKind.ThisKeyword:

src/server/editorServices.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -2705,15 +2705,14 @@ namespace ts.server {
27052705
// It was then postponed to cleanup these script infos so that they can be reused if
27062706
// the file from that old project is reopened because of opening file from here.
27072707
this.removeOrphanScriptInfos();
2708-
2709-
this.printProjects();
27102708
}
27112709

27122710
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult {
27132711
const info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath);
27142712
const { defaultConfigProject, ...result } = this.assignProjectToOpenedScriptInfo(info);
27152713
this.cleanupAfterOpeningFile(defaultConfigProject);
27162714
this.telemetryOnOpenFile(info);
2715+
this.printProjects();
27172716
return result;
27182717
}
27192718

@@ -2914,12 +2913,16 @@ namespace ts.server {
29142913
this.assignOrphanScriptInfosToInferredProject();
29152914
}
29162915

2917-
// Cleanup projects
2918-
this.cleanupAfterOpeningFile(defaultConfigProjects);
2919-
2920-
// Telemetry
2921-
forEach(openScriptInfos, info => this.telemetryOnOpenFile(info));
2922-
this.printProjects();
2916+
if (openScriptInfos) {
2917+
// Cleanup projects
2918+
this.cleanupAfterOpeningFile(defaultConfigProjects);
2919+
// Telemetry
2920+
openScriptInfos.forEach(info => this.telemetryOnOpenFile(info));
2921+
this.printProjects();
2922+
}
2923+
else if (length(closedFiles)) {
2924+
this.printProjects();
2925+
}
29232926
}
29242927

29252928
/* @internal */

0 commit comments

Comments
 (0)