@zxsylph/dbml-formatter 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/formatter/formatter.ts +11 -4
package/package.json
CHANGED
|
@@ -203,7 +203,7 @@ export function format(input: string, options: FormatterOptions = {}): string {
|
|
|
203
203
|
const newLineTokens = [...line];
|
|
204
204
|
newLineTokens[newLineTokens.length - 1] = {
|
|
205
205
|
...last,
|
|
206
|
-
value:
|
|
206
|
+
value: '\n'
|
|
207
207
|
};
|
|
208
208
|
normalized.push(newLineTokens);
|
|
209
209
|
|
|
@@ -660,10 +660,13 @@ export function format(input: string, options: FormatterOptions = {}): string {
|
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
// Apply spacing based on GLOBAL `output`
|
|
663
|
+
if (token.type === TokenType.Symbol && token.value === '}') {
|
|
664
|
+
indentLevel--;
|
|
665
|
+
if (indentLevel < 0) indentLevel = 0;
|
|
666
|
+
}
|
|
667
|
+
|
|
663
668
|
if (output.endsWith('\n')) {
|
|
664
|
-
|
|
665
|
-
output += getIndent();
|
|
666
|
-
}
|
|
669
|
+
output += getIndent();
|
|
667
670
|
} else if (output.length > 0) {
|
|
668
671
|
let needsSpace = true;
|
|
669
672
|
const lastChar = output[output.length - 1];
|
|
@@ -722,6 +725,10 @@ export function format(input: string, options: FormatterOptions = {}): string {
|
|
|
722
725
|
break;
|
|
723
726
|
}
|
|
724
727
|
|
|
728
|
+
if (token.type === TokenType.Symbol && token.value === '{') {
|
|
729
|
+
indentLevel++;
|
|
730
|
+
}
|
|
731
|
+
|
|
725
732
|
i++;
|
|
726
733
|
}
|
|
727
734
|
|