-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(inspect): ensure non-compact output when object literal has newline in entry text #18366
fix(inspect): ensure non-compact output when object literal has newline in entry text #18366
Conversation
I will look into why it's formatting this way for short paths actually. |
args: "run run/nested_error.ts", | ||
output: "run/nested_error.ts.out", | ||
args: "run run/nested_error/main.ts", | ||
output: "run/nested_error/main.ts.out", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally moved this file to increase the path length, but I kept it here as part of this PR because it's less cluttered.
totalLength > LINE_BREAKING_LENGTH || | ||
!inspectOptions.compact || | ||
StringPrototypeIncludes(entriesText, "\n") | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to write a test, but you can see here this is fixed:
> cargo run
Deno 1.31.3
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> Deno.inspect({ test: new Error() })
"{\n test: Error\n at <anonymous>:3:11\n}"
> close()
> deno
Deno 1.31.3+8bcffff
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> Deno.inspect({ test: new Error() })
"{ test: Error\n at <anonymous>:3:11 }"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, this one was fun to debug.
Fixes
Deno.inspect
to make an object literal non-compact when an entry has multiple lines in it.Edit: Old information below
I develop in
V:\deno
and this test was failing for me because the file path was short enough that it changed the formatting. For example:This PR moves the test into a sub directory, which will cause the formatting to be the same for long and short dev paths.