| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e3a0a9c commit 5ed8a1c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1931,8 +1931,11 @@ function reduceToSingleString( | |||
| 1931 | 1931 | const start = output.length + ctx.indentationLvl + | |
| 1932 | 1932 | braces[0].length + base.length + 10; | |
| 1933 | 1933 | if (isBelowBreakLength(ctx, output, start, base)) { | |
| 1934 | - return `${base ? `${base} ` : ''}${braces[0]} ${join(output, ', ')}` + | ||
| 1935 | - ` ${braces[1]}`; | ||
| 1934 | + const joinedOutput = join(output, ', '); | ||
| 1935 | + if (!joinedOutput.includes('\n')) { | ||
| 1936 | + return `${base ? `${base} ` : ''}${braces[0]} ${joinedOutput}` + | ||
| 1937 | + ` ${braces[1]}`; | ||
| 1938 | + } | ||
| 1936 | 1939 | } | |
| 1937 | 1940 | } | |
| 1938 | 1941 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2631,6 +2631,24 @@ assert.strictEqual( | |||
| 2631 | 2631 | ||
| 2632 | 2632 | assert.strictEqual(out, expected); | |
| 2633 | 2633 | ||
| 2634 | + // Array grouping should prevent lining up outer elements on a single line. | ||
| 2635 | + obj = [[[1, 2, 3, 4, 5, 6, 7, 8, 9]]]; | ||
| 2636 | + | ||
| 2637 | + out = util.inspect(obj, { compact: 3 }); | ||
| 2638 | + | ||
| 2639 | + expected = [ | ||
| 2640 | + '[', | ||
| 2641 | + ' [', | ||
| 2642 | + ' [', | ||
| 2643 | + ' 1, 2, 3, 4, 5,', | ||
| 2644 | + ' 6, 7, 8, 9', | ||
| 2645 | + ' ]', | ||
| 2646 | + ' ]', | ||
| 2647 | + ']', | ||
| 2648 | + ].join('\n'); | ||
| 2649 | + | ||
| 2650 | + assert.strictEqual(out, expected); | ||
| 2651 | + | ||
| 2634 | 2652 | // Verify that array grouping and line consolidation does not happen together. | |
| 2635 | 2653 | obj = { | |
| 2636 | 2654 | a: { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments