Skip to content

console.table output in debug console loses its colors when using launch program #168924

Closed

Description

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version:
    Version: 1.74.0 (Universal)
    Commit: 5235c6b
    Date: 2022-12-05T16:43:37.594Z
    Electron: 19.1.8
    Chromium: 102.0.5005.167
    Node.js: 16.14.2
    V8: 10.2.154.15-electron.0
    OS: Darwin x64 21.6.0
    Sandboxed: No
  • OS Version: 12.6.1

Steps to Reproduce:

  1. Create a node.js file called index.js with this content
console.table([{a: '1', b: 1}])
  1. Run node index.js and you'll see the following output in the console where the b column is properly colored:

Screen Shot 2022-12-12 at 6 20 02 PM

  1. However, if you run the program from the Run and debug button in the Run panel, you lose the colors:

Screen Shot 2022-12-12 at 6 21 06 PM

Creating the default launch.json file results in the same incorrect output

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"type": "node",
			"request": "launch",
			"name": "Launch Program",
			"skipFiles": [
				"<node_internals>/**"
			],
			"program": "${workspaceFolder}/index.js"
		}
	]
}

Activity

  1. roblourens commented on Dec 13, 2022

    @roblourens
    Member

    It works if you set "console": "integratedTerminal". I think that is just the behavior of console.table- it only sends colors if the program is detected to be running in a tty environment that it knows can interpret them.

  2. mhkeller commented on Dec 13, 2022

    @mhkeller
    Author

    Thanks!

  3. mhkeller commented on Jan 10, 2023

    @mhkeller
    Author

    roblourens sorry one more question on this. If I hit F5 on a new script and there is no launch.json file, it launches the script in debug mode, which is nice and easy, but I lose the colors. Is there a way to have the default behavior, — without creating a launch.json script — be to use this integratedTerminal option?

    Also, it seems that F5 will launch the script specified in the "main" field of my package.json. Is there a way to have F5 run the currently active script, whatever that may be?

    My ideal workflow would be to use F5 / Shift-F5 to start / stop the current script I'm working on and to show console output with all of the supported colors. Thanks for your help.

  4. roblourens commented on Jan 11, 2023

    @roblourens
    Member

    I don't think we have something like this currently, cc Connor Peet (@connor4312) to be sure

  5. connor4312 commented on Jan 11, 2023

    @connor4312
    Member

    Correct, we don't currently support that

  6. mhkeller commented on Jan 11, 2023

    @mhkeller
    Author

    Thanks for letting me know. I could break this into a few issues if it's something possible to pursue. I don't know the debug architecture well enough to know how well properly tailored these are but here is a start of two issues I can open if they aren't completely off base and not feasible.

    1. "Allow for global debug settings" These settings would apply to debug sessions started by F5 for projects without a launch.json. This would allow me to set the integratedTerminal option as the default.
    2. "If no launch.json, F5 debugs current active file." I think I was mistaken that F5 runs the debug script on what is specified in the package.json. I can't actually quite figure out how it chooses which script to run. What is the current logic?

    [edit I was able to have F5 run the current file, as described in the docs, by changing the dropdown in the debug console to be "Run current file" instead of "Launch program"]

  7. mhkeller commented on Jan 17, 2023

    @mhkeller
    Author

    I found one more inconsistency when it comes to color highlighting. I can open a new issue if that helps but maybe I'm simply doing something wrong.

    When using "console": "integratedTerminal", and I console.table` an array of objects, I get the nice coloring. But if I just console.log a string and a number, they show up both in blue
    Screen Shot 2023-01-17 at 4 31 59 PM

    versus green and yellow when put into a table

    Screen Shot 2023-01-17 at 4 35 00 PM

  8. roblourens commented on Jan 17, 2023

    @roblourens
    Member

    Same deal, the coloring in the terminal is on the "frontend", the debug messages that we get don't contain any color information, and vscode doesn't apply any colorization to debug console messages by default. I'm not sure it makes sense for vscode to do that for all messages generically. I think it would have to be a feature request for js-debug, if you think that we should be coloring these messages.

  9. mhkeller commented on Jan 17, 2023

    @mhkeller
    Author

    Ah that's too bad – I thought setting "console": "integratedTerminal" would fix it in all scenarios. I'm not sure I would ever not want it to be colored but I imagine there is some computation cost?

    As background, I think the REPL is super useful and am using more and more for Jupyter-style cell-like execution but without the whole added infrastructure of that setup. Bringing the interactive REPL to node programming opens up so many possibilities.

    Even if it were something you could set in .vsode/launch.json that would be great – I would just set up my script template with that flagged. Is that this repo? I can file an issue there if that's the most appropriate place.

  10. locked and limited conversation to collaborators on Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions