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

Problem with colors when parameters contain object #172868

Closed
svallory opened this issue Jan 7, 2023 · 1 comment · Fixed by microsoft/vscode-js-debug#1547
Closed

Problem with colors when parameters contain object #172868

svallory opened this issue Jan 7, 2023 · 1 comment · Fixed by microsoft/vscode-js-debug#1547
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@svallory
Copy link

svallory commented Jan 7, 2023

Describe the bug
Logged messages with colors and objects do not display correctly on Debug Console. Messages without objects display correctly.

To Reproduce

import Debugger from 'debug';
const debug = Debugger('cva:init');
debug('Initializing');
debug({ a: 4 });

Log File

Relevant launch configuration

{
      "name": "Attach to Figma",
      "type": "chrome",
      "request": "attach",
      "address": "localhost",
      "port": 9222,
      "targetSelection": "pick",
      "pauseForSourceMap": true,
      "pathMapping": {
        "/file/": "${workspaceRoot}/",
        "../src/": "${workspaceRoot}/src/",
        "src/": "${workspaceRoot}/src/"
      },
      "outFiles": [
        "${workspaceFolder}/build/*.js",
        "${workspaceFolder}/build/*.js.map",
      ],
      "presentation": {
        "hidden": false,
        "group": "Figma",
        "order": 2,
      },
      "internalConsoleOptions": "openOnSessionStart"
    }

VS Code Version: 1.74.2

Additional context

NOTE: I added BEFORE FORMAT and AFTER FORMAT to the debug library to check what it was doing

image

EDIT

An easier way to reproduce. Type this directly on the debug console:

console.log('%cThis %cWorks %c +1ms', 'color: #00CC00', 'color: inherit', 'color: #00CC00');
console.log('%cThis %cDOES NOT %c +1ms %o', 'color: #00CC00', 'color: inherit', 'color: #00CC00', []);

image

@svallory svallory added the bug Issue identified by VS Code Team member as probable bug label Jan 7, 2023
@connor4312 connor4312 transferred this issue from microsoft/vscode-js-debug Jan 30, 2023
@microsoft microsoft deleted a comment from vscodenpa Jan 30, 2023
@connor4312
Copy link
Member

This is actually a VS Code bug, in part at least. ANSI color sequences are supported in top level expressions, but not in variables values. If an output has a variablesReference, the value of that variable is shown instead of any output string that might be included (so js-debug always emits an empty string in this case).

I think the best way to deal with this is tweak how we show output in VS Code, showing a non-empty output string if it exists and then pulling the variable and on expansion.

fyi @roblourens might try to tack this today/tomorrow

@connor4312 connor4312 added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jan 30, 2023
@connor4312 connor4312 added this to the February 2023 milestone Jan 30, 2023
connor4312 added a commit that referenced this issue Jan 31, 2023
Previously, if a DAP output event contained a variablesReference, we
would entirely ignore the `output` text in favor of shows its variables.
However, output can be richer than variable data: namely, it can show
ANSI sequences which would be inappropriate to format in
a variable `value`.

In this PR, if an output event has a single variable in its
`variablesReference` and output text, we show the output text instead
of the variable value. (Maybe we should also log output as plain text,
though this could be a confusing experience. I don't know of any DA's
that actually emit >1 variable in their output.)

For #172868
For #171732

(will need adoption in js-debug to actually fix those)
connor4312 added a commit that referenced this issue Feb 1, 2023
Previously, if a DAP output event contained a variablesReference, we
would entirely ignore the `output` text in favor of shows its variables.
However, output can be richer than variable data: namely, it can show
ANSI sequences which would be inappropriate to format in
a variable `value`.

In this PR, if an output event has a single variable in its
`variablesReference` and output text, we show the output text instead
of the variable value. (Maybe we should also log output as plain text,
though this could be a confusing experience. I don't know of any DA's
that actually emit >1 variable in their output.)

For #172868
For #171732

(will need adoption in js-debug to actually fix those)
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Feb 3, 2023
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Feb 3, 2023
@rzhao271 rzhao271 added verified Verification succeeded and removed verified Verification succeeded labels Feb 23, 2023
@meganrogge meganrogge added the verified Verification succeeded label Feb 23, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants