Skip to content
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

Not working in VSCode debug console #218

Open
jpike88 opened this issue Mar 12, 2018 · 22 comments
Open

Not working in VSCode debug console #218

jpike88 opened this issue Mar 12, 2018 · 22 comments

Comments

@jpike88
Copy link
Contributor

jpike88 commented Mar 12, 2018

The first image is how it looks in the debug console

screen shot 2018-03-12 at 5 20 52 pm

The second image is how it looks in the VSCode integrated terminal (or normal OSX terminal)

screen shot 2018-03-12 at 5 20 59 pm

@DABH
Copy link
Contributor

DABH commented Mar 14, 2018

Is this a colors issue or a vscode issue? microsoft/vscode#45572

@jpike88
Copy link
Contributor Author

jpike88 commented Mar 15, 2018

Good question lol

@jpike88 jpike88 closed this as completed Mar 15, 2018
@jpike88
Copy link
Contributor Author

jpike88 commented Mar 15, 2018

microsoft/vscode#21423

@jpike88
Copy link
Contributor Author

jpike88 commented Mar 15, 2018

Closed, but worth reading the above link. What do you think

@jpike88 jpike88 reopened this Mar 19, 2018
@jpike88
Copy link
Contributor Author

jpike88 commented Mar 19, 2018

@DABH any comments on this?

microsoft/vscode#21423 (comment)

@DABH
Copy link
Contributor

DABH commented Mar 25, 2018

Interesting; we should investigate the order in which ANSI codes are emitted (seems like we're doing it a bit backwards eh?). I'm not sure if there are any unintended consequences if we flip the order though -- seems like a core change so we would have to be very very careful. If you'd like to play around with this, feel free and let us know the results. It seems the VSCode people have largely gotten this working so I'll leave this open as a low-priority item to investigate in the future.

@danielfrankcom
Copy link

Hey, just popping in incase you need me, I was the one making the most recent changes to the VSCode display stuff. The ordering problem does seem a bit weird to me, seems like it's almost more of a philosophical question than anything else. With the way that the class hierarchy works in the VSCode console HTML, I think it would require a decent redesign to account for more complicated cases where things are in different orders, though that may not actually be a bad idea. I haven't thought about it too deeply, but I can definitely think of more advanced situations where the current system wouldn't be sufficient. I'd be interested to know how many other debug consoles support your ordering as it stands, because if they all do, then it may be something that needs changing on our end.

@jpike88
Copy link
Contributor Author

jpike88 commented Apr 3, 2018

Oh my god. I found the problem.

colors.supportsColor returns false on esm-enabled projects. That's not good.

@jpike88
Copy link
Contributor Author

jpike88 commented Apr 3, 2018

Ok that was premature, ignore. But I'm close

@jpike88
Copy link
Contributor Author

jpike88 commented Apr 3, 2018

if (stream && !stream.isTTY && forceColor !== true) {

My stream object has the _type property set to "pipe", instead of "tty". This makes the isTTY check fail, and I get no styling.

The weird part is that a fresh node project has colors coming through somewhat alright, but in my main working project, I get no styling at all. There's something going on with my project's configuration that would create this issue, but I have no idea what.

However my code looks like this:

import colors from 'colors'; var test = colors.green('wattttt') console.log(test)

And my launch.json looks like this:

{ "type": "node", "request": "launch", "name": "API", "program": "${workspaceFolder}/bin/api-server.js", "cwd": "${workspaceRoot}", "runtimeArgs": [ "-r", "esm" ] }

In the meantime I'll use the "FORCE_COLOR" environment variable to fix this.

I'm not sure if this is my fault, a bug with colors.js or a bug with VSCode...

@jpike88
Copy link
Contributor Author

jpike88 commented Apr 3, 2018

Bonus weirdness, works fine with another developer's project. I'm on OSX and he's on Windows 10. And I've double check I have the latest colors.js installed in mine.

@jpike88
Copy link
Contributor Author

jpike88 commented Apr 3, 2018

Only thing remaining now is the fact that the colors on ANSI codes break if newlines are present in the string.

The white output should be yellow, but its only doing it for the first line.

screen shot 2018-04-03 at 1 17 24 pm

@jpike88
Copy link
Contributor Author

jpike88 commented Apr 3, 2018

I've fixed that...

#220

Other than the yellow seeming really dark, and I was about to implement custom colour functionality, when I saw these:

#76
#67

I'd like to be a collaborator, you've got PRs going back almost 4 years. I have the time and energy to clean this repo up.

@DABH
Copy link
Contributor

DABH commented Apr 3, 2018

Thanks for investigating @jpike88 ! I've recently started triaging and going through all the issues and PRs -- things have already been cleaned up quite a bit in the past month or two. Custom colors is in the roadmap for the next minor release; we want to do it right, so it'll require some careful review, but this is definitely upcoming. We'd definitely welcome any help reviewing PRs like those, or PRs that fix any outstanding bugs (e.g. #167 seems similar to this issue).

Meanwhile I've left some comments on #220

@danielfrankcom Thanks for dropping in : ) I believe colors works in at least a few other IDE debug consoles (e.g. Webstorm), but I haven't done a thorough investigation to determine support (an interesting project for someone to investigate!). colors is known to work in most console environments as well (Powershell, git bash, etc., etc.), so it does seem like a lot of systems do support this ordering of the color codes. Would be great, one way or another, to reach full compatibility with VSCode though!

@weinand
Copy link

weinand commented May 31, 2018

Please see my analysis of the problem:
microsoft/vscode#47457 (comment) and microsoft/vscode#47457 (comment).

@iansan5653
Copy link

iansan5653 commented May 24, 2019

microsoft/vscode#71458, microsoft/vscode#70502, and microsoft/vscode#70935 fix a lot of issues with coloring text in the debug console. I would guess that if you try it again now, the problem will most likely be resolved. Let me know and if something else needs to be fixed on the VSCode side, I'll take a look at it.

@rahulmathews
Copy link

Any updates on this issue? I am able to repro the bug when used with colors module. I am able to console log the colors in my internal terminal, but When I use it with my debug console, I am unable to do it.

Following are the version specs:

Version: 1.55.1
Commit: 08a217c4d27a02a5bcde898fd7981bda5b49391b
Date: 2021-04-07T15:01:24.315Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.4.0-70-generic

@sheadawson
Copy link

This does not appear to be resolved to date

@iansan5653
Copy link

@sheadawson @rahulmathews Can you provide an example? I am able to see colors in both the terminal and console.

Using this basic script:

const colors = require("colors/safe");

console.log(colors.green('hello'));

I am able to see green in the terminal:
image

And in the debug console:
image

@Rahul-Mathews
Copy link

Rahul-Mathews commented Aug 28, 2021

@sheadawson @rahulmathews Can you provide an example? I am able to see colors in both the terminal and console.

Using this basic script:

const colors = require("colors/safe");

console.log(colors.green('hello'));

I am able to see green in the terminal:
image

And in the debug console:
image

Try this script

   const colors = require("colors");


   console.log("hello".green.bold);

String prototype function for color not working for me. It works in terminal though interestingly it fails while using node debugger in vscode. And Your code still shows the default blue color in debug console while using console log in my vs code

@iansan5653
Copy link

iansan5653 commented Aug 29, 2021

Try this script

   const colors = require("colors");


   console.log("hello".green.bold);

That works for me as well:
image

I tried other colors too:
image

Please share output of Help -> About -> Copy. Maybe this is a VSCode bug on some operating systems.

@Rahul-Mathews
Copy link

Try this script

   const colors = require("colors");


   console.log("hello".green.bold);

That works for me as well:
image

I tried other colors too:
image

Please share output of Help -> About -> Copy. Maybe this is a VSCode bug on some operating systems.

This is my version specs:

Version: 1.59.1
Commit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
Date: 2021-08-19T11:54:37.513Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Linux x64 5.11.0-27-generic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants