mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
improve indentation when displaying objects with console.log (#5909)
This commit is contained in:
parent
088fc1556c
commit
6d9b06619d
1 changed files with 5 additions and 9 deletions
|
@ -124,23 +124,19 @@ function createIterableString<T>(
|
|||
|
||||
const iPrefix = `${config.displayName ? config.displayName + " " : ""}`;
|
||||
|
||||
const initIndentation = `\n${DEFAULT_INDENT.repeat(level + 1)}`;
|
||||
const entryIndentation = `,\n${DEFAULT_INDENT.repeat(level + 1)}`;
|
||||
const closingIndentation = `\n${DEFAULT_INDENT.repeat(level)}`;
|
||||
|
||||
let iContent: string;
|
||||
if (config.group && entries.length > MIN_GROUP_LENGTH) {
|
||||
const groups = groupEntries(entries, level, value);
|
||||
const initIndentation = `\n${DEFAULT_INDENT.repeat(level + 1)}`;
|
||||
const entryIndentation = `,\n${DEFAULT_INDENT.repeat(level + 1)}`;
|
||||
const closingIndentation = `\n${DEFAULT_INDENT.repeat(level)}`;
|
||||
|
||||
iContent = `${initIndentation}${groups.join(
|
||||
entryIndentation
|
||||
)}${closingIndentation}`;
|
||||
} else {
|
||||
iContent = entries.length === 0 ? "" : ` ${entries.join(", ")} `;
|
||||
if (stripColor(iContent).length > LINE_BREAKING_LENGTH) {
|
||||
const initIndentation = `\n${DEFAULT_INDENT.repeat(level + 1)}`;
|
||||
const entryIndentation = `,\n${DEFAULT_INDENT.repeat(level + 1)}`;
|
||||
const closingIndentation = `\n`;
|
||||
|
||||
iContent = `${initIndentation}${entries.join(
|
||||
entryIndentation
|
||||
)}${closingIndentation}`;
|
||||
|
@ -343,7 +339,7 @@ function createArrayString(
|
|||
const ending = emptyItems > 1 ? "s" : "";
|
||||
return dim(`<${emptyItems} empty item${ending}>`);
|
||||
} else {
|
||||
return stringifyWithQuotes(val, ctx, level + 1, maxLevel);
|
||||
return stringifyWithQuotes(val, ctx, level, maxLevel);
|
||||
}
|
||||
},
|
||||
group: true,
|
||||
|
|
Loading…
Reference in a new issue