diff options
author | Speykious <speykious.the.king@gmail.com> | 2020-05-28 15:04:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 09:04:43 -0400 |
commit | 6d9b06619d242ccaae5e735e0f8316950e00c6b5 (patch) | |
tree | 8b87f47d18dbda87d4a977d3a64de2a4721957ed /cli/js | |
parent | 088fc1556c5bc51cf85485aa622ccfa2f34145e7 (diff) |
improve indentation when displaying objects with console.log (#5909)
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/web/console.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/cli/js/web/console.ts b/cli/js/web/console.ts index 622181030..0e17d2efb 100644 --- a/cli/js/web/console.ts +++ b/cli/js/web/console.ts @@ -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, |