Skip to content

Commit

Permalink
fix(language-core): avoid interpolation indentation affecting each other
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Mar 27, 2024
1 parent 993fcec commit ff4b7ea
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/language-core/lib/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const presetInfos = {
const formatBrackets = {
normal: ['`${', '}`;'] as [string, string],
// fix https://github.com/vuejs/language-tools/issues/3572
params: ['(', ') => {}'] as [string, string],
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],
Expand Down Expand Up @@ -483,7 +483,7 @@ export function* generate(
start,
lines.length <= 1 ? formatBrackets.curly : [
lines[0].trim() === '' ? '(' : formatBrackets.curly[0],
lines[lines.length - 1].trim() === '' ? ')' : formatBrackets.curly[1],
lines[lines.length - 1].trim() === '' ? ');' : formatBrackets.curly[1],
],
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineFormatTest } from '../utils/format';

defineFormatTest({
title: '#' + __filename.split('.')[0],
languageId: 'vue',
input: `
<template>
{{
foo
}}
{{
bar
}}
</template>
`.trim(),
output: `
<template>
{{
foo
}}
{{
bar
}}
</template>
`.trim(),
});

0 comments on commit ff4b7ea

Please sign in to comment.