From a21e9b20842cd11d793bbf4d03e3b71206d254f1 Mon Sep 17 00:00:00 2001 From: nighca Date: Fri, 10 Jan 2025 18:11:42 +0800 Subject: [PATCH] refresh LS result on project change --- .../editor/code-editor/ui/diagnostics/index.ts | 17 ++++++----------- .../code-editor/ui/resource-reference/index.ts | 17 ++++++----------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/spx-gui/src/components/editor/code-editor/ui/diagnostics/index.ts b/spx-gui/src/components/editor/code-editor/ui/diagnostics/index.ts index e12da30ec..c922736cd 100644 --- a/spx-gui/src/components/editor/code-editor/ui/diagnostics/index.ts +++ b/spx-gui/src/components/editor/code-editor/ui/diagnostics/index.ts @@ -41,17 +41,6 @@ export class DiagnosticsController extends Disposable { init() { const refreshDiagnostics = debounce(() => this.diagnosticsMgr.start(), 100) - this.addDisposer( - watch( - () => this.ui.activeTextDocument, - (textDocument, _, onCleanup) => { - if (textDocument == null) return - refreshDiagnostics() - onCleanup(textDocument.on('didChangeContent', refreshDiagnostics)) - }, - { immediate: true } - ) - ) this.addDisposer( watch( this.providerRef, @@ -63,5 +52,11 @@ export class DiagnosticsController extends Disposable { { immediate: true } ) ) + + this.addDisposer(watch( + () => this.ui.project.filesHash, + () => refreshDiagnostics(), + { immediate: true } + )) } } diff --git a/spx-gui/src/components/editor/code-editor/ui/resource-reference/index.ts b/spx-gui/src/components/editor/code-editor/ui/resource-reference/index.ts index f345c7c13..a40b2c657 100644 --- a/spx-gui/src/components/editor/code-editor/ui/resource-reference/index.ts +++ b/spx-gui/src/components/editor/code-editor/ui/resource-reference/index.ts @@ -95,17 +95,6 @@ export class ResourceReferenceController extends Emitter<{ const refreshItems = debounce(() => this.itemsMgr.start(), 100) - this.addDisposer( - watch( - () => this.ui.activeTextDocument, - (textDocument, _, onCleanup) => { - if (textDocument == null) return - refreshItems() - onCleanup(textDocument.on('didChangeContent', refreshItems)) - }, - { immediate: true } - ) - ) this.addDisposer( watch( this.providerRef, @@ -118,6 +107,12 @@ export class ResourceReferenceController extends Emitter<{ ) ) + this.addDisposer(watch( + () => this.ui.project.filesHash, + () => refreshItems(), + { immediate: true } + )) + const editorEl = editor.getDomNode() if (editorEl == null) throw new Error('No editor dom node')