Skip to content

Commit

Permalink
fix(compiler-sfc): preserve old deindent behavior for pug
Browse files Browse the repository at this point in the history
fix #12611
  • Loading branch information
yyx990803 committed Jul 5, 2022
1 parent fb93c1b commit 1294385
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/compiler-sfc/src/parseComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const DEFAULT_FILENAME = 'anonymous.vue'
const splitRE = /\r?\n/g
const replaceRE = /./g
const isSpecialTag = makeMap('script,style,template', true)
const isNeedIndentLang = makeMap('pug,jade')

export interface SFCCustomBlock {
type: string
Expand Down Expand Up @@ -177,7 +178,11 @@ export function parseComponent(
if (depth === 1 && currentBlock) {
currentBlock.end = start
let text = source.slice(currentBlock.start, currentBlock.end)
if (options.deindent) {
if (
options.deindent ||
// certain langs like pug are indent sensitive, preserve old behavior
(currentBlock.lang && isNeedIndentLang(currentBlock.lang))
) {
text = deindent(text)
}
// pad content so that linters and pre-processors can output correct
Expand Down

0 comments on commit 1294385

Please sign in to comment.