From 0ac03ae5cd15be689e7806c038269eb162bc5bf0 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 18 Sep 2020 20:22:52 +0200 Subject: [PATCH] Fixes microsoft/monaco-editor#1638: Protect against failing `getCodeFixesAtPosition` calls --- src/tsWorker.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/tsWorker.ts b/src/tsWorker.ts index f2a29fc..049234a 100644 --- a/src/tsWorker.ts +++ b/src/tsWorker.ts @@ -313,14 +313,18 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork formatOptions: ts.FormatCodeOptions ): Promise> { const preferences = {}; - return this._languageService.getCodeFixesAtPosition( - fileName, - start, - end, - errorCodes, - formatOptions, - preferences - ); + try { + return this._languageService.getCodeFixesAtPosition( + fileName, + start, + end, + errorCodes, + formatOptions, + preferences + ); + } catch { + return []; + } } async updateExtraLibs(extraLibs: IExtraLibs): Promise {