From 8e632b8b76e5da8494e833414e292eef83d0f5ac Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Sat, 21 Dec 2024 03:58:16 +0800 Subject: [PATCH] Update computedSfc.ts --- packages/language-core/lib/virtualFile/computedSfc.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/language-core/lib/virtualFile/computedSfc.ts b/packages/language-core/lib/virtualFile/computedSfc.ts index d0965e1e5f..2cd17d523c 100644 --- a/packages/language-core/lib/virtualFile/computedSfc.ts +++ b/packages/language-core/lib/virtualFile/computedSfc.ts @@ -25,8 +25,15 @@ export function computedSfc( const content = computed(() => { return snapshot.get().getText(0, snapshot.get().getLength()); }); - const comments = computed(() => { - return parsed.get()?.descriptor.comments ?? []; + const comments = computed(oldValue => { + const newValue = parsed.get()?.descriptor.comments ?? []; + if ( + oldValue?.length === newValue.length + && oldValue.every((v, i) => v === newValue[i]) + ) { + return oldValue; + } + return newValue; }); const template = computedNullableSfcBlock( 'template',