Skip to content

Commit

Permalink
🐛 consoleInspect() Map with wrap: single-line doesn't work well
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Feb 20, 2024
1 parent def4fd2 commit c734cfe
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/inspect/inspectors/inspectIterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import indent from "../../utils/indent";
import isPrimitive from "../../utils/isPrimitive";
import ConsoleInspection from "../utils/ConsoleInspection";
import inspectInline from "./inspectInline";
import { inspectObjectMultiLine } from "./inspectObject";
import { inspectObject } from "./inspectObject";

export function inspectIterable(
iterable: Iterable<unknown>,
Expand Down Expand Up @@ -56,10 +56,13 @@ export function inspectIterableSingleLine(
spans: [
consoleText(info.subtype === undefined ? "[" : "{"),
...info.array.flatMap((value, i) => {
const inspection = inspectAny(value, options, {
...context,
depth: context.depth + 1,
});
const inspection =
info.subtype === "Map"
? inspectEntry(value, options, context)
: inspectAny(value, options, {
...context,
depth: context.depth + 1,
});
return i === 0
? inspection.spans
: [consoleText(", "), ...inspection.spans];
Expand Down Expand Up @@ -126,7 +129,7 @@ function inspectEntry(
});

if (!isPrimitive(key)) {
return inspectObjectMultiLine({ key, value }, options, {
return inspectObject({ key, value }, options, {
depth: context.depth,
wrap: Math.max(context.wrap - options.indent, 0),
});
Expand Down

0 comments on commit c734cfe

Please sign in to comment.