Skip to content

can not output string with color in debug console after update to 1.22.1 #47457

Closed

Description

@lerit
  • VSCode Version:1.22.1
  • OS Version:win10

Steps to Reproduce:

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:
image 5
debug console:
image 6

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

Activity

  1. added
    debug
    on Apr 9, 2018
  2. ScriptKi77y commented on Apr 12, 2018

    @ScriptKi77y

    I also noticed this after the update.

    2018-04-12_07-37-38

  3. isidorn commented on Apr 23, 2018

    @isidorn

    Daniel Frankcom (@danielfrankcom) this seems to have broke with your pr #45946

    Would you be interested in fixing this issue?

  4. danielfrankcom commented on Apr 24, 2018

    @danielfrankcom
    Contributor

    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!

  5. isidorn commented on Apr 24, 2018

    @isidorn

    Daniel Frankcom (@danielfrankcom) great. Tackle it when you have time then, assigning this to May so we do not hurry.

  6. danielfrankcom commented on Apr 30, 2018

    @danielfrankcom
    Contributor

    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:
    image

    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.

  7. isidorn commented on Apr 30, 2018

    @isidorn

    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.

  8. danielfrankcom commented on May 3, 2018

    @danielfrankcom
    Contributor

    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...

    image

  9. 14 remaining items

  10. weinand commented on May 31, 2018

    @weinand
    Contributor

    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).

  11. weinand commented on May 31, 2018

    @weinand
    Contributor

    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.

  12. isidorn commented on May 31, 2018

    @isidorn

    Andre Weinand (@weinand) great catch and good anlaysis. Thanks!
    Should we close as duplicate then?

  13. weinand commented on May 31, 2018

    @weinand
    Contributor

    No, #50340 has the background info but would not fix this.
    Leave it open until I understand the problem (and a workaround/fix).

  14. weinand commented on May 31, 2018

    @weinand
    Contributor

    The npm module "colors" (https://www.npmjs.com/package/colors) relies on stream.isTTY and 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 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.

  15. added a commit that references this issue on Jun 4, 2018
  16. locked and limited conversation to collaborators on Jul 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debugverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions