@zxsylph/dbml-formatter 1.0.13 → 1.0.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zxsylph/dbml-formatter",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "",
5
5
  "files": [
6
6
  "bin",
@@ -41,7 +41,7 @@ export function format(input: string, options: FormatterOptions = {}): string {
41
41
  if (t.type === TokenType.Symbol && (t.value === '}' || t.value === '{')) break;
42
42
  if (t.type === TokenType.Word) {
43
43
  // Check case-insensitive
44
- if (t.value.toLowerCase() === 'table') {
44
+ if (t.value.toLowerCase().startsWith('table')) {
45
45
  isTable = true;
46
46
  break;
47
47
  }
@@ -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
- if (token.value !== '}') {
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