diff --git a/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts b/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts index 5583f86c..aed90e0d 100644 --- a/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts +++ b/packages/typescript/lib/quickstart/createAsyncLanguageServicePlugin.ts @@ -75,7 +75,6 @@ export function createAsyncLanguageServicePlugin( info.languageService = proxy; create(ts, info).then(({ languagePlugins, setup }) => { - const syncedScriptVersions = new FileMap(ts.sys.useCaseSensitiveFileNames); const language = createLanguage( [ ...languagePlugins, @@ -83,19 +82,11 @@ export function createAsyncLanguageServicePlugin( ], new FileMap(ts.sys.useCaseSensitiveFileNames), fileName => { - const version = getScriptVersion(fileName); - if (syncedScriptVersions.get(fileName) === version) { - return; - } - syncedScriptVersions.set(fileName, version); - - const snapshot = getScriptSnapshot(fileName); + const snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); if (snapshot) { - language.scripts.set( - fileName, - snapshot - ); - } else { + 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 a12a5ca8..c13f95c9 100644 --- a/packages/typescript/lib/quickstart/createLanguageServicePlugin.ts +++ b/packages/typescript/lib/quickstart/createLanguageServicePlugin.ts @@ -34,9 +34,6 @@ export function createLanguageServicePlugin( .map(plugin => plugin.typescript?.extraFileExtensions.map(ext => '.' + ext.extension) ?? []) .flat(); projectExternalFileExtensions.set(info.project, extensions); - const getScriptSnapshot = info.languageServiceHost.getScriptSnapshot.bind(info.languageServiceHost); - const getScriptVersion = info.languageServiceHost.getScriptVersion.bind(info.languageServiceHost); - const syncedScriptVersions = new FileMap(ts.sys.useCaseSensitiveFileNames); const language = createLanguage( [ ...languagePlugins, @@ -44,13 +41,7 @@ export function createLanguageServicePlugin( ], new FileMap(ts.sys.useCaseSensitiveFileNames), fileName => { - const version = getScriptVersion(fileName); - if (syncedScriptVersions.get(fileName) === version) { - return; - } - syncedScriptVersions.set(fileName, version); - - const snapshot = getScriptSnapshot(fileName); + const snapshot = info.project.getScriptInfo(fileName)?.getSnapshot(); if (snapshot) { language.scripts.set(fileName, snapshot); }