Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

util.inspect short arrays still end up being distributed on new lines #5039

Closed
FTPlus opened this Issue · 1 comment

2 participants

@FTPlus

When using util.inspect with colored output relatively small arrays and objects still end up on multiple lines. I guess this is caused by the fact that the color-codes are also included in the line width calculation.

example case:

 // Ends up on a single line as intended:
console.log(require('util').inspect([1,2,3,4,5,6], {colors: false}))
// Is split up over multiple lines:
console.log(require('util').inspect([1,2,3,4,5,6], {colors: true})) 

It's not really a vital problem but it makes printing larges objects much more readable. Maybe a regexp to strip out the color-codes when calculating the line width would do the trick?

@bnoordhuis

Possibly. Extremely low priority issue but patches are welcome. :-)

@bnoordhuis bnoordhuis closed this issue from a commit
@kustosz kustosz util: fix util.inspect() line width calculation
Have the formatter filter out vt100 color codes when calculating the
line width. Stops it from unnecessarily splitting strings over multiple
lines.

Fixes #5039.
1f55704
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.