Skip to content

Commit

Permalink
fix: 馃悰 nested switch directive gets unexpected format
Browse files Browse the repository at this point in the history
  • Loading branch information
shufo committed Feb 20, 2022
1 parent 97b4595 commit 865cadf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,16 @@ export default class Formatter {
content,
new RegExp(`(\\s*?)(${directive})(\\s*?)${nestedParenthesisRegex}(\\s*)`, 'gmi'),
(match) => {
return `${match.trim()}\n`;
return `\n${match.trim()}\n`;
},
);
});

// eslint-disable-next-line
content = _.replace(content, /@case\S*?\s*?@case/gim, (match) => {
return `${match.replace('\n', '')}`;
});

const unbalancedEchos = ['@break'];

_.forEach(unbalancedEchos, (directive) => {
Expand Down Expand Up @@ -1118,7 +1123,6 @@ export default class Formatter {
if (token === '@endswitch' && _.last(this.stack) === '@default') {
this.decrementIndentLevel(2);
this.shouldBeIndent = false;
this.stack.pop();
return;
}

Expand Down

0 comments on commit 865cadf

Please sign in to comment.