From eea8096abea29525a5d691ab832d6c2b89b75fc1 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei-Da" <36730922+jasonlyu123@users.noreply.github.com> Date: Fri, 24 Nov 2023 22:35:07 +0800 Subject: [PATCH] Update packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> --- .../typescript/features/DiagnosticsProvider.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts index 53181994b..dc6b61f81 100644 --- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts @@ -84,16 +84,13 @@ export class DiagnosticsProviderImpl implements DiagnosticsProvider { const checkers = [lang.getSuggestionDiagnostics, lang.getSemanticDiagnostics]; for (const checker of checkers) { - if (!cancellationToken) { - diagnostics.push(...checker.call(lang, tsDoc.filePath)); - continue; - } - - // wait a bit so the event loop can check for cancellation - // or let completion go first - await new Promise((resolve) => setTimeout(resolve, 10)); - if (cancellationToken.isCancellationRequested) { - return []; + if (cancellationToken) { + // wait a bit so the event loop can check for cancellation + // or let completion go first + await new Promise((resolve) => setTimeout(resolve, 10)); + if (cancellationToken.isCancellationRequested) { + return []; + } } diagnostics.push(...checker.call(lang, tsDoc.filePath)); }