diff --git a/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts b/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts index ecad5679..a4c42c10 100644 --- a/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts +++ b/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts @@ -82,20 +82,23 @@ export function createAsyncLanguageServicePlugin( ], new FileMap(ts.sys.useCaseSensitiveFileNames), fileName => { + let snapshot: ts.IScriptSnapshot | undefined; + try { // getSnapshot could be crashed if the file is too large - let snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); + snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); if (!snapshot) { // trigger projectService.getOrCreateScriptInfoNotOpenedByClient info.project.getScriptVersion(fileName); snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); } - if (snapshot) { - language.scripts.set(fileName, snapshot); - } - else { - language.scripts.delete(fileName); - } } catch { } + + if (snapshot) { + language.scripts.set(fileName, snapshot); + } + else { + language.scripts.delete(fileName); + } } ); diff --git a/packages/typescript/lib/quickstart/createLanguageServicePlugin.ts b/packages/typescript/lib/quickstart/createLanguageServicePlugin.ts index f03447b6..b4eef62a 100644 --- a/packages/typescript/lib/quickstart/createLanguageServicePlugin.ts +++ b/packages/typescript/lib/quickstart/createLanguageServicePlugin.ts @@ -41,20 +41,23 @@ export function createLanguageServicePlugin( ], new FileMap(ts.sys.useCaseSensitiveFileNames), fileName => { + let snapshot: ts.IScriptSnapshot | undefined; + try { // getSnapshot could be crashed if the file is too large - let snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); + snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); if (!snapshot) { // trigger projectService.getOrCreateScriptInfoNotOpenedByClient info.project.getScriptVersion(fileName); snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); } - if (snapshot) { - language.scripts.set(fileName, snapshot); - } - else { - language.scripts.delete(fileName); - } } catch { } + + if (snapshot) { + language.scripts.set(fileName, snapshot); + } + else { + language.scripts.delete(fileName); + } } );