From 603629aa0d7372c96f8641aa8b940ea45e3999bb Mon Sep 17 00:00:00 2001 From: johnsoncodehk Date: Fri, 6 Jan 2023 21:43:44 +0800 Subject: [PATCH] fix: should not send parseSfc request when preview server closed --- vue-language-tools/vscode-vue/src/features/preview.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vue-language-tools/vscode-vue/src/features/preview.ts b/vue-language-tools/vscode-vue/src/features/preview.ts index 633a71c4d..3123a23a4 100644 --- a/vue-language-tools/vscode-vue/src/features/preview.ts +++ b/vue-language-tools/vscode-vue/src/features/preview.ts @@ -284,10 +284,10 @@ export async function register(context: vscode.ExtensionContext, client: BaseLan } async function updateSelectionHighlights(textEditor: vscode.TextEditor) { - if (textEditor.document.languageId === 'vue' && highlightDomElements) { + if (connection && textEditor.document.languageId === 'vue' && highlightDomElements) { const sfc = await getSfc(textEditor.document); const offset = sfc.descriptor.template?.loc.start.offset ?? 0; - connection?.highlight( + connection.highlight( textEditor.document.fileName, textEditor.selections.map(selection => ({ start: textEditor.document.offsetAt(selection.start) - offset,