diff --git a/packages/vue-language-core/src/generators/template.ts b/packages/vue-language-core/src/generators/template.ts index 5da34f4ae..c015b2bb3 100644 --- a/packages/vue-language-core/src/generators/template.ts +++ b/packages/vue-language-core/src/generators/template.ts @@ -38,6 +38,8 @@ const capabilitiesPresets = { }; const formatBrackets = { normal: ['`${', '}`;'] as [string, string], + // fix https://github.com/vuejs/language-tools/issues/3572 + params: ['(', ') => {}'] as [string, string], // fix https://github.com/vuejs/language-tools/issues/1210 // fix https://github.com/vuejs/language-tools/issues/2305 curly: ['0 +', '+ 0;'] as [string, string], @@ -868,12 +870,12 @@ export function generate( ...createFormatCode( slotDir.exp.content, slotDir.exp.loc.start.offset, - formatBrackets.normal, + formatBrackets.params, ), ); - const collectAst = createTsAst(slotDir, `(${slotDir.exp.content}) => {}`); - colletVars(ts, collectAst, slotBlockVars); + const slotAst = createTsAst(slotDir, `(${slotDir.exp.content}) => {}`); + colletVars(ts, slotAst, slotBlockVars); hasProps = true; if (slotDir.exp.content.indexOf(':') === -1) { codes.push( diff --git a/packages/vue-language-service/tests/format/3572.spec.ts b/packages/vue-language-service/tests/format/3572.spec.ts new file mode 100644 index 000000000..f74172f22 --- /dev/null +++ b/packages/vue-language-service/tests/format/3572.spec.ts @@ -0,0 +1,13 @@ +import { defineFormatTest } from '../utils/format'; + +defineFormatTest({ + title: '#' + __filename.split('.')[0], + languageId: 'vue', + input: ` +