Skip to content

Commit cc7a0b6

Browse files
committed
Fix issue 547
1 parent 60d1543 commit cc7a0b6

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/printer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,8 @@ export class PugPrinter {
17931793
}
17941794

17951795
private async code(token: CodeToken): Promise<string> {
1796-
let result: string = this.computedIndent;
1796+
let result: string =
1797+
this.previousToken?.type === 'tag' ? '' : this.computedIndent;
17971798
if (!token.mustEscape && token.buffer) {
17981799
result += '!';
17991800
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template lang="pug">
2+
ul
3+
each val in [1, 2, 3, 4, 5]
4+
li= val
5+
</template>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { compareFiles } from 'tests/common';
2+
import { describe, expect, it } from 'vitest';
3+
4+
describe('Issues', () => {
5+
it('should handle tag code while pugSingleFileComponentIndentation is enabled', async () => {
6+
const { actual, expected } = await compareFiles(import.meta.url, {
7+
source: 'unformatted.vue',
8+
target: 'formatted.vue',
9+
formatOptions: {
10+
parser: 'vue',
11+
pugFramework: 'vue',
12+
pugSingleFileComponentIndentation: true,
13+
},
14+
});
15+
expect(actual).toBe(expected);
16+
});
17+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template lang="pug">
2+
ul
3+
each val in [1, 2, 3, 4, 5]
4+
li= val
5+
</template>

0 commit comments

Comments
 (0)