You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
can not output string with color in debug console after update to 1.22.1 #47457
1.i use colors package to colorful my output
console.log(colors.green('hello')+" world")
this will output string "hello world" that "hello" with color green(debug console,terminal)
this work fine in v1.21.1
2.after upgrade to v.1.22.1,it still work fine in terminal,but not work in debug console,
all the text color is green,not only 'hello'
terminal:
debug console:
Does this issue occur when all extensions are disabled?: Yes/No
yes
While I was looking at the code again, I've noticed discrepencies in the way that various ANSI codes are being handled. This, in combination with the issue that prompted my changes originally, have led to a rewrite of the whole ANSI handling function. It should be much more robust when I'm done, but I have a question regarding your preference for currently unsupported ANSI codes.
This code for example is currently unsupported by us:
Would we like to print out [K, or hide the code on the debug console entirely? The actions taken currently vary substantially, so I'd like to define a specific way of handling situations like this. Certain codes such as Esc[123456m (which is completely invalid) are currently ignored, while the code mentioned above is printed to the console as [K.
Daniel Frankcom (@danielfrankcom) first of all thanks for looking into this.
As for what to do in that specific scenario: my preference would be to not show it because that would be consistent with some other places where we strip out ansi escape code
However I could also be convinced to show it if you are leaning towards that.
While I'm at it, I'm adding background colours as they're not currently supported. I'd like to add high-intensity colours too, but the colours all seem a bit off. I wanted to check, are there any sort of guidelines for maximum colour intensity? Certainly on the dark theme, yellow looks more like mud...
When running out of source the adapters are identical to the ones in Insiders (because they are loaded from the Marketplace).
So it cannot be something in the adapter.
(And when using an integrated or external terminal the colors show up fine too).
When running Insiders from the command line, the colors work fine because the environment has been configured properly by a preceding login-shell or terminal emulator.
And colors fail when running Insiders from the Finder where there is no preceding login-shell (and where VS Code tries to simulate the login behaviour but obviously fails for "color").
And when using an integrated or external terminal colors work fine because both run as login-shells and are terminal emulators.
Since the debug console in VS Code is not based on a TTY, the check fails and colors becomes a no-op. In addition VS Code does not define any of the environment variables used in "colors" probing code when launched from the Finder.
As a workaround we could use an undocumented "FORCE_COLOR" environment variable of the "colors" module:
"env": {
"FORCE_COLOR": "10"
},
However this workaround would only work for the "colors" module and probably not for anything else. So adding this variable to the VS Code environment automatically, doesn't help much (and I'm not planning to fix this issue on the VS Code side).
I suggest that the "colors" module documents the use of stream.isTTY and the "FORCE_COLOR" variable so that the workaround becomes more obvious.
Activity
ScriptKi77y commentedon Apr 12, 2018
I also noticed this after the update.
isidorn commentedon Apr 23, 2018
Daniel Frankcom (@danielfrankcom) this seems to have broke with your pr #45946
Would you be interested in fixing this issue?
danielfrankcom commentedon Apr 24, 2018
Yeah I definately can, but not for a little while. If someone else wants to take a crack at it in the mean time go right ahead!
isidorn commentedon Apr 24, 2018
Daniel Frankcom (@danielfrankcom) great. Tackle it when you have time then, assigning this to May so we do not hurry.
danielfrankcom commentedon Apr 30, 2018
Hey Isidor Nikolic (@isidorn), I'm working on this issue now.
While I was looking at the code again, I've noticed discrepencies in the way that various ANSI codes are being handled. This, in combination with the issue that prompted my changes originally, have led to a rewrite of the whole ANSI handling function. It should be much more robust when I'm done, but I have a question regarding your preference for currently unsupported ANSI codes.
This code for example is currently unsupported by us:

Would we like to print out
[K, or hide the code on the debug console entirely? The actions taken currently vary substantially, so I'd like to define a specific way of handling situations like this. Certain codes such asEsc[123456m(which is completely invalid) are currently ignored, while the code mentioned above is printed to the console as[K.isidorn commentedon Apr 30, 2018
Daniel Frankcom (@danielfrankcom) first of all thanks for looking into this.
As for what to do in that specific scenario: my preference would be to not show it because that would be consistent with some other places where we strip out ansi escape code
However I could also be convinced to show it if you are leaning towards that.
danielfrankcom commentedon May 3, 2018
Isidor Nikolic (@isidorn) Sound good.
Unless you think it really matters, I'm going to match all numbers from 0-107 as valid codes despite certain ranges not really being included as real ANSI codes. (https://en.wikipedia.org/wiki/ANSI_escape_code)
While I'm at it, I'm adding background colours as they're not currently supported. I'd like to add high-intensity colours too, but the colours all seem a bit off. I wanted to check, are there any sort of guidelines for maximum colour intensity? Certainly on the dark theme, yellow looks more like mud...
14 remaining items
weinand commentedon May 31, 2018
When running out of source the adapters are identical to the ones in Insiders (because they are loaded from the Marketplace).
So it cannot be something in the adapter.
(And when using an integrated or external terminal the colors show up fine too).
weinand commentedon May 31, 2018
It is (again) the environment, stupid...
When running Insiders from the command line, the colors work fine because the environment has been configured properly by a preceding login-shell or terminal emulator.
And colors fail when running Insiders from the Finder where there is no preceding login-shell (and where VS Code tries to simulate the login behaviour but obviously fails for "color").
And when using an integrated or external terminal colors work fine because both run as login-shells and are terminal emulators.
See for more background info in #50340.
isidorn commentedon May 31, 2018
Andre Weinand (@weinand) great catch and good anlaysis. Thanks!
Should we close as duplicate then?
weinand commentedon May 31, 2018
No, #50340 has the background info but would not fix this.
Leave it open until I understand the problem (and a workaround/fix).
weinand commentedon May 31, 2018
The npm module "colors" (https://www.npmjs.com/package/colors) relies on
stream.isTTYand some environment variables to figure out whether colors are supported.Since the debug console in VS Code is not based on a TTY, the check fails and
colorsbecomes a no-op. In addition VS Code does not define any of the environment variables used in "colors" probing code when launched from the Finder.As a workaround we could use an undocumented "FORCE_COLOR" environment variable of the "colors" module:
However this workaround would only work for the "colors" module and probably not for anything else. So adding this variable to the VS Code environment automatically, doesn't help much (and I'm not planning to fix this issue on the VS Code side).
I suggest that the "colors" module documents the use of
stream.isTTYand the "FORCE_COLOR" variable so that the workaround becomes more obvious.Merge pull request #49764 from danielfrankcom/#47457/background