util: allow single-line format when break length is infinite - #64238
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. |
038a50a to
b91c45e
Compare
31523f9 to
3060df3
Compare
ede2dd7 to
34da682
Compare
|
@ljharb All formatting, linting, and core test suites are now fully passing (29/30 checks successful). The single remaining check (test-macOS) failed on an unrelated debugger timeout (test-debugger-exceptions.js 15000ms exceeded), which appears to be a macOS CI runner flake. Could you please re-run that failed macOS job when you have a moment to review? |
|
@hamidrezaghavami again, your test case already passes, so it's not a regression test. |
|
@ljharb To clarify my intent: this patch is a performance early exit fast path inside isBelowBreakLength when breakLength === Infinity, avoiding unnecessary string width calculation loops. Because observable output is identical to main, standard tests pass on both branches. Should we label/track this strictly as a performance optimization/cleanup rather than a bug fix? |
|
ahh ok, that wasn't clear to me before |
34da682 to
31719ca
Compare
Signed-off-by: Hamid Reza Ghavami <hamidr.ghavami@gmail.com>
31719ca to
a881d0e
Compare
|
@ljharb The CI checks are fully green! I had to force-push one last time to shorten the test string to pass the 80-character max-len linter rule. Could you re-approve when you have a moment, so we can get this merged? |
This comment was marked as resolved.
This comment was marked as resolved.
|
Hey team! Just checking in on this. It looks like it has all necessary approvals, but the checks are failing on some unrelated flaky tests. Could a maintainer please help re-run the CI or let me know if any further action is needed? Thanks! |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Landed in f509cf1 |
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