Skip to content

Commit c2427f2

Browse files
committed
Wrap the cancellation token in throttled cancellation token from server
1 parent 1507547 commit c2427f2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/server/project.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ namespace ts.server {
167167

168168
private typingFiles: SortedReadonlyArray<string>;
169169

170+
private readonly cancellationToken: ThrottledCancellationToken;
171+
170172
public isNonTsProject() {
171173
this.updateGraph();
172174
return allFilesAreJsOrDts(this);
@@ -206,6 +208,7 @@ namespace ts.server {
206208
/*@internal*/public directoryStructureHost: DirectoryStructureHost,
207209
rootDirectoryForResolution: string | undefined) {
208210

211+
this.cancellationToken = new ThrottledCancellationToken(this.projectService.cancellationToken, this.projectService.throttleWaitMilliseconds);
209212
if (!this.compilerOptions) {
210213
this.compilerOptions = getDefaultCompilerOptions();
211214
this.compilerOptions.allowNonTsExtensions = true;
@@ -294,7 +297,7 @@ namespace ts.server {
294297
}
295298

296299
getCancellationToken() {
297-
return this.projectService.cancellationToken;
300+
return this.cancellationToken;
298301
}
299302

300303
getCurrentDirectory(): string {

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7091,6 +7091,7 @@ declare namespace ts.server {
70917091
*/
70927092
private projectStateVersion;
70937093
private typingFiles;
7094+
private readonly cancellationToken;
70947095
isNonTsProject(): boolean;
70957096
isJsOnlyProject(): boolean;
70967097
getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap;
@@ -7103,7 +7104,7 @@ declare namespace ts.server {
71037104
getScriptKind(fileName: string): ScriptKind;
71047105
getScriptVersion(filename: string): string;
71057106
getScriptSnapshot(filename: string): IScriptSnapshot;
7106-
getCancellationToken(): HostCancellationToken;
7107+
getCancellationToken(): ThrottledCancellationToken;
71077108
getCurrentDirectory(): string;
71087109
getDefaultLibFileName(): string;
71097110
useCaseSensitiveFileNames(): boolean;

0 commit comments

Comments
 (0)