Skip to content

Commit

Permalink
fix: format adds spaces to v-for if nested template element assigns…
Browse files Browse the repository at this point in the history
… type to slot props

close #2750, close #2757
  • Loading branch information
johnsoncodehk committed May 3, 2023
1 parent c5c025c commit de308a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vue-language-core/src/generators/template.ts
Expand Up @@ -36,10 +36,11 @@ const capabilitiesPresets = {
refAttr: { references: true, definition: true, rename: true } satisfies FileRangeCapabilities,
};
const formatBrackets = {
normal: ['`${', '}`'] as [string, string],
normal: ['`${', '}`;'] as [string, string],
// fix https://github.com/johnsoncodehk/volar/issues/1210
// fix https://github.com/johnsoncodehk/volar/issues/2305
curly: ['0 +', '+ 0;'] as [string, string],
event: ['() => ', ';'] as [string, string],
};
const validTsVar = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
// @ts-ignore
Expand Down Expand Up @@ -939,7 +940,7 @@ export function generate(
...createFormatCode(
prop.exp.content,
prop.exp.loc.start.offset,
formatBrackets.normal,
isCompoundExpression ? formatBrackets.event : formatBrackets.normal,
),
);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/vue-test-workspace/format/#2750/input.vue
@@ -0,0 +1,6 @@
<template>
<a-select v-model:value="modelSelectValue">
<a-select-option v-for="item of executorModel" :key="item" :value="item"
@click="modelSelectValue = item; modelSelectOpen = 0;">{{ item }}</a-select-option>
</a-select>
</template>
6 changes: 6 additions & 0 deletions packages/vue-test-workspace/format/#2750/output.vue
@@ -0,0 +1,6 @@
<template>
<a-select v-model:value="modelSelectValue">
<a-select-option v-for="item of executorModel" :key="item" :value="item"
@click="modelSelectValue = item; modelSelectOpen = 0;">{{ item }}</a-select-option>
</a-select>
</template>

0 comments on commit de308a8

Please sign in to comment.