diff --git a/src/bun.js/ConsoleObject.zig b/src/bun.js/ConsoleObject.zig index 33ebd2fa14..9def500ece 100644 --- a/src/bun.js/ConsoleObject.zig +++ b/src/bun.js/ConsoleObject.zig @@ -2728,10 +2728,6 @@ pub const Formatter = struct { this.quote_strings = true; defer this.quote_strings = prev_quote_strings; - if (!this.single_line) { - this.writeIndent(Writer, writer_) catch {}; - } - const set_name = if (value.jsType() == .WeakSet) "WeakSet" else "Set"; if (length == 0) { @@ -2762,7 +2758,7 @@ pub const Formatter = struct { }, } } - if (this.single_line) { + if (!this.single_line) { this.writeIndent(Writer, writer_) catch {}; } writer.writeAll("}"); diff --git a/test/regression/issue/16007.test.ts b/test/regression/issue/16007.test.ts new file mode 100644 index 0000000000..fa09d4fedc --- /dev/null +++ b/test/regression/issue/16007.test.ts @@ -0,0 +1,12 @@ +import { it, expect } from "bun:test"; + +it("Set is propperly formatted in Bun.inspect()", () => { + const set = new Set(["foo", "bar"]); + const formatted = Bun.inspect({ set }); + expect(formatted).toBe(`{ + set: Set(2) { + "foo", + "bar", + }, +}`); +});