fix(inspect): allow single-line format when breakLength is Infinity#64238
fix(inspect): allow single-line format when breakLength is Infinity#64238hamidrezaghavami wants to merge 3 commits into
Conversation
ljharb
left a comment
There was a problem hiding this comment.
this definitely needs tests to cover the changed behavior. ideally, you'd also provide the tests' output absent this change.
|
Hello, @ljharb The single-line formatting behaviour when breakLength is set to Infinity is covered in a test case that I have provided. |
| { // test case | ||
| const obj = { a: 1, b: 2, c: 3, d: 4 }; | ||
| const result = util.inspect(obj, { breakLength: Infinity }); | ||
| assert.strictEqual(result, '{ a: 1, b: 2, c: 3, d: 4 }'); |
There was a problem hiding this comment.
i get this result on node already. we'd need a test case that breaks without the fix.
cb241a4 to
3981926
Compare
3981926 to
1b7315c
Compare
Description
When calling
util.inspect()with abreakLengthconfiguration explicitly set toInfinity, the internal layout formatting logic should bypass multi-line chunking and formatting constraints entirely, allowing the contents to naturally evaluate on a single line.Currently,
isBelowBreakLengthgoes through a character length loop calculation even when length checks are logically unnecessary due to the infinite upper bound. This change introduces an explicit early return branch withinisBelowBreakLengthwhenctx.breakLength === Infinity, properly enabling a clean, un-wrapped single-line string formatting mode.Checklist