summaryrefslogtreecommitdiff
path: root/lib/internal/util/inspect.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/util/inspect.js')
-rw-r--r--lib/internal/util/inspect.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index 9280e2ac5f..87e53d62f6 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -1342,7 +1342,7 @@ function formatProperty(ctx, value, recurseTimes, key, type) {
return `${name}:${extra}${str}`;
}
-function isBelowBreakLength(ctx, output, start) {
+function isBelowBreakLength(ctx, output, start, base) {
// Each entry is separated by at least a comma. Thus, we start with a total
// length of at least `output.length`. In addition, some cases have a
// whitespace in-between each other that is added to the total as well.
@@ -1359,7 +1359,8 @@ function isBelowBreakLength(ctx, output, start) {
return false;
}
}
- return true;
+ // Do not line up properties on the same line if `base` contains line breaks.
+ return base === '' || !base.includes('\n');
}
function reduceToSingleString(ctx, output, base, braces, combine = false) {
@@ -1370,7 +1371,7 @@ function reduceToSingleString(ctx, output, base, braces, combine = false) {
// that may reduce `breakLength`.
const start = output.length + ctx.indentationLvl +
braces[0].length + base.length + 10;
- if (isBelowBreakLength(ctx, output, start)) {
+ if (isBelowBreakLength(ctx, output, start, base)) {
return `${base ? `${base} ` : ''}${braces[0]} ${join(output, ', ')} ` +
braces[1];
}
@@ -1382,7 +1383,7 @@ function reduceToSingleString(ctx, output, base, braces, combine = false) {
}
// Line up all entries on a single line in case the entries do not exceed
// `breakLength`.
- if (isBelowBreakLength(ctx, output, 0)) {
+ if (isBelowBreakLength(ctx, output, 0, base)) {
return `${braces[0]}${base ? ` ${base}` : ''} ${join(output, ', ')} ` +
braces[1];
}