diff --git a/packages/language-server/src/lib/documents/DocumentManager.ts b/packages/language-server/src/lib/documents/DocumentManager.ts index 68b377a9e..8617560da 100644 --- a/packages/language-server/src/lib/documents/DocumentManager.ts +++ b/packages/language-server/src/lib/documents/DocumentManager.ts @@ -16,7 +16,6 @@ export type DocumentEvent = 'documentOpen' | 'documentChange' | 'documentClose'; */ export class DocumentManager { private emitter = new EventEmitter(); - // private openedInClient: FileSet; private documents: FileMap; private locked: FileSet; private deleteCandidates: FileSet; @@ -67,10 +66,10 @@ export class DocumentManager { } markAsOpenedInClient(uri: string): void { - // const document = this.documents.get(normalizeUri(uri)); - // if (document) { - // document.openedByClient = true; - // } + const document = this.documents.get(normalizeUri(uri)); + if (document) { + document.openedByClient = true; + } } getAllOpenedByClient() { diff --git a/packages/language-server/src/plugins/typescript/service.ts b/packages/language-server/src/plugins/typescript/service.ts index 47ba71f3c..5d7f6ea27 100644 --- a/packages/language-server/src/plugins/typescript/service.ts +++ b/packages/language-server/src/plugins/typescript/service.ts @@ -82,11 +82,6 @@ const configFileModifiedTime = new FileMap(); const configFileForOpenFiles = new FileMap(); const pendingReloads = new FileSet(); -process.on('exit', () => { - // so that the schedule update doesn't keep the process open - forAllServices((service) => service.dispose()); -}); - /** * For testing only: Reset the cache for services. * Try to refactor this some day so that this file provides @@ -175,6 +170,7 @@ export async function getServiceForTsconfig( Logger.log('Reloading ts service at ', tsconfigPath, ' due to config updated'); } else { Logger.log('Initialize new ts service at ', tsconfigPath); + console.trace(); } pendingReloads.delete(tsconfigPath); @@ -267,7 +263,6 @@ async function createLanguageService( let languageServiceReducedMode = false; let projectVersion = 0; let dirty = false; - let timer: NodeJS.Timeout | undefined; const getCanonicalFileName = createGetCanonicalFileName(tsSystem.useCaseSensitiveFileNames); @@ -427,6 +422,7 @@ async function createLanguageService( function updateProjectFiles(): void { projectVersion++; + dirty = true; const projectFileCountBefore = snapshotManager.getProjectFileNames().length; snapshotManager.updateProjectFiles(); const projectFileCountAfter = snapshotManager.getProjectFileNames().length; @@ -630,7 +626,6 @@ async function createLanguageService( } function dispose() { - clearTimeout(timer); languageService.dispose(); snapshotManager.dispose(); configWatchers.get(tsconfigPath)?.close(); @@ -704,10 +699,6 @@ async function createLanguageService( } function updateIfDirty() { - if (timer) { - clearTimeout(timer); - timer = undefined; - } if (!dirty) { return; } @@ -719,14 +710,13 @@ async function createLanguageService( } function scheduleUpdate() { - projectVersion++; - dirty = true; - - if (timer) { - clearTimeout(timer); + if (dirty) { + return; } - timer = setTimeout(updateIfDirty, 1000); + projectVersion++; + dirty = true; + console.log('scheduleUpdate'); } } diff --git a/packages/language-server/src/server.ts b/packages/language-server/src/server.ts index 83a12ccb3..3a27f5a35 100644 --- a/packages/language-server/src/server.ts +++ b/packages/language-server/src/server.ts @@ -347,7 +347,6 @@ export function startServer(options?: LSOptions) { connection.onDidOpenTextDocument((evt) => { const document = docManager.openClientDocument(evt.textDocument); - docManager.markAsOpenedInClient(evt.textDocument.uri); diagnosticsManager.scheduleUpdate(document); }); diff --git a/packages/language-server/src/svelte-check.ts b/packages/language-server/src/svelte-check.ts index 8c0451486..4e5c3c6ae 100644 --- a/packages/language-server/src/svelte-check.ts +++ b/packages/language-server/src/svelte-check.ts @@ -140,7 +140,6 @@ export class SvelteCheck { text: doc.text, uri: doc.uri }); - this.docManager.markAsOpenedInClient(doc.uri); } }