File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -1919,7 +1919,10 @@ pub const Formatter = struct {
1919
1919
if (ctx .i == 0 ) {
1920
1920
handleFirstProperty (ctx , globalThis , ctx .parent ) catch return ;
1921
1921
} else {
1922
- this .printComma (Writer , writer_ , enable_ansi_colors ) catch unreachable ;
1922
+ const len = ctx .parent .getLength (globalThis ) catch 0 ;
1923
+ if (len > 0 ) {
1924
+ this .printComma (Writer , writer_ , enable_ansi_colors ) catch unreachable ;
1925
+ }
1923
1926
}
1924
1927
1925
1928
defer ctx .i += 1 ;
@@ -2381,8 +2384,28 @@ pub const Formatter = struct {
2381
2384
// }
2382
2385
2383
2386
if (len == 0 ) {
2384
- writer .writeAll ("[]" );
2385
- this .addForNewLine (2 );
2387
+ writer .writeAll ("[" );
2388
+ this .addForNewLine (1 );
2389
+ if (! jsType .isArguments ()) {
2390
+ const Iterator = PropertyIterator (Writer , enable_ansi_colors );
2391
+ var iter = Iterator {
2392
+ .formatter = this ,
2393
+ .writer = writer_ ,
2394
+ .always_newline = ! this .single_line and (this .always_newline_scope or this .goodTimeForANewLine ()),
2395
+ .single_line = this .single_line ,
2396
+ .parent = value ,
2397
+ .i = 1 ,
2398
+ };
2399
+ try value .forEachPropertyNonIndexed (this .globalThis , & iter , Iterator .forEach );
2400
+ if (this .failed ) return ;
2401
+
2402
+ const keys = try value .keys (this .globalThis );
2403
+ const num_keys = try keys .getLength (this .globalThis );
2404
+ if (num_keys > 0 ) {
2405
+ writer .writeAll (" " );
2406
+ }
2407
+ }
2408
+ writer .writeAll ("]" );
2386
2409
return ;
2387
2410
}
2388
2411
You can’t perform that action at this time.
0 commit comments