Skip to content

Commit c5f560e

Browse files
committed
cleanup, remove setTimeout updates for now
not sure if it make a huge difference
1 parent 742fec2 commit c5f560e

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

packages/language-server/src/lib/documents/DocumentManager.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export type DocumentEvent = 'documentOpen' | 'documentChange' | 'documentClose';
1616
*/
1717
export class DocumentManager {
1818
private emitter = new EventEmitter();
19-
// private openedInClient: FileSet;
2019
private documents: FileMap<Document>;
2120
private locked: FileSet;
2221
private deleteCandidates: FileSet;
@@ -67,10 +66,10 @@ export class DocumentManager {
6766
}
6867

6968
markAsOpenedInClient(uri: string): void {
70-
// const document = this.documents.get(normalizeUri(uri));
71-
// if (document) {
72-
// document.openedByClient = true;
73-
// }
69+
const document = this.documents.get(normalizeUri(uri));
70+
if (document) {
71+
document.openedByClient = true;
72+
}
7473
}
7574

7675
getAllOpenedByClient() {

packages/language-server/src/plugins/typescript/service.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ const configFileModifiedTime = new FileMap<Date | undefined>();
8282
const configFileForOpenFiles = new FileMap<string>();
8383
const pendingReloads = new FileSet();
8484

85-
process.on('exit', () => {
86-
// so that the schedule update doesn't keep the process open
87-
forAllServices((service) => service.dispose());
88-
});
89-
9085
/**
9186
* For testing only: Reset the cache for services.
9287
* Try to refactor this some day so that this file provides
@@ -175,6 +170,7 @@ export async function getServiceForTsconfig(
175170
Logger.log('Reloading ts service at ', tsconfigPath, ' due to config updated');
176171
} else {
177172
Logger.log('Initialize new ts service at ', tsconfigPath);
173+
console.trace();
178174
}
179175

180176
pendingReloads.delete(tsconfigPath);
@@ -267,7 +263,6 @@ async function createLanguageService(
267263
let languageServiceReducedMode = false;
268264
let projectVersion = 0;
269265
let dirty = false;
270-
let timer: NodeJS.Timeout | undefined;
271266

272267
const getCanonicalFileName = createGetCanonicalFileName(tsSystem.useCaseSensitiveFileNames);
273268

@@ -427,6 +422,7 @@ async function createLanguageService(
427422

428423
function updateProjectFiles(): void {
429424
projectVersion++;
425+
dirty = true;
430426
const projectFileCountBefore = snapshotManager.getProjectFileNames().length;
431427
snapshotManager.updateProjectFiles();
432428
const projectFileCountAfter = snapshotManager.getProjectFileNames().length;
@@ -630,7 +626,6 @@ async function createLanguageService(
630626
}
631627

632628
function dispose() {
633-
clearTimeout(timer);
634629
languageService.dispose();
635630
snapshotManager.dispose();
636631
configWatchers.get(tsconfigPath)?.close();
@@ -704,10 +699,6 @@ async function createLanguageService(
704699
}
705700

706701
function updateIfDirty() {
707-
if (timer) {
708-
clearTimeout(timer);
709-
timer = undefined;
710-
}
711702
if (!dirty) {
712703
return;
713704
}
@@ -719,14 +710,13 @@ async function createLanguageService(
719710
}
720711

721712
function scheduleUpdate() {
722-
projectVersion++;
723-
dirty = true;
724-
725-
if (timer) {
726-
clearTimeout(timer);
713+
if (dirty) {
714+
return;
727715
}
728716

729-
timer = setTimeout(updateIfDirty, 1000);
717+
projectVersion++;
718+
dirty = true;
719+
console.log('scheduleUpdate');
730720
}
731721
}
732722

packages/language-server/src/server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ export function startServer(options?: LSOptions) {
347347

348348
connection.onDidOpenTextDocument((evt) => {
349349
const document = docManager.openClientDocument(evt.textDocument);
350-
docManager.markAsOpenedInClient(evt.textDocument.uri);
351350
diagnosticsManager.scheduleUpdate(document);
352351
});
353352

packages/language-server/src/svelte-check.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ export class SvelteCheck {
140140
text: doc.text,
141141
uri: doc.uri
142142
});
143-
this.docManager.markAsOpenedInClient(doc.uri);
144143
}
145144
}
146145

0 commit comments

Comments
 (0)