MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / dispose

Method dispose

src/cm/lsp/clientManager.ts:463–518  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

461 }
462
463 async dispose(): Promise<void> {
464 try {
465 interface FileWithSession {
466 id?: string;
467 type?: string;
468 session?: EditorState;
469 }
470
471 interface EditorManagerLike {
472 files?: FileWithSession[];
473 editor?: EditorView;
474 activeFile?: FileWithSession;
475 }
476
477 const em = (globalThis as Record<string, unknown>).editorManager as
478 | EditorManagerLike
479 | undefined;
480
481 if (em?.editor) {
482 try {
483 em.editor.dispatch({ effects: clearDiagnosticsEffect() });
484 if (em.activeFile?.type === "editor") {
485 em.activeFile.session = em.editor.state;
486 }
487 } catch {
488 /* View may be disposed */
489 }
490 }
491
492 if (em?.files) {
493 for (const file of em.files) {
494 if (file?.type !== "editor" || file.id === em.activeFile?.id)
495 continue;
496 const session = file.session;
497 if (session && typeof session.update === "function") {
498 try {
499 file.session = session.update({
500 effects: clearDiagnosticsEffect(),
501 }).state;
502 } catch {
503 /* State update failed */
504 }
505 }
506 }
507 }
508 } catch {
509 /* Ignore errors */
510 }
511
512 const disposeOps: Promise<void>[] = [];
513 for (const [key, state] of this.#clients.entries()) {
514 disposeOps.push(state.dispose());
515 this.#clients.delete(key);
516 }
517 await Promise.allSettled(disposeOps);
518 }
519
520 async #ensureClient(

Callers 4

EditorManagerFunction · 0.45
runFunction · 0.45
#initializeClientMethod · 0.45

Calls 4

clearDiagnosticsEffectFunction · 0.90
deleteMethod · 0.65
disconnectMethod · 0.65
updateMethod · 0.45

Tested by

no test coverage detected