From 5c28cf412152714ee5ffeb1e87b767ef35bbac08 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Fri, 3 Jan 2025 09:45:47 +0800 Subject: [PATCH] fix(language-core): slot exp formatting virtual code syntax incorrect --- .../lib/plugins/vue-template-inline-ts.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/language-core/lib/plugins/vue-template-inline-ts.ts b/packages/language-core/lib/plugins/vue-template-inline-ts.ts index 0c85960ad7..125454d60f 100644 --- a/packages/language-core/lib/plugins/vue-template-inline-ts.ts +++ b/packages/language-core/lib/plugins/vue-template-inline-ts.ts @@ -113,6 +113,13 @@ const plugin: VueLanguagePlugin = ctx => { : formatBrackets.normal ); } + else if (prop.name === 'slot') { + addFormatCodes( + prop.exp.content, + prop.exp.loc.start.offset, + formatBrackets.params + ); + } else { addFormatCodes( prop.exp.content, @@ -149,11 +156,11 @@ const plugin: VueLanguagePlugin = ctx => { let start = leftExpressionRange.start; let end = source.loc.start.offset + source.content.length; while (templateContent[start - 1] === ' ' || templateContent[start - 1] === '(') { - start--; -} + start--; + } while (templateContent[end] === ' ' || templateContent[end] === ')') { - end++; -} + end++; + } addFormatCodes( templateContent.slice(start, end), start,