2

I am implementing a custom debugger using the debug adapter protocol for VS Code (version 1.26.1). The debug adapter is written in Java and uses LSP4J 0.5.0M1 to communicate with the client.

Basic launching and evaluating expression already works. I am able to enter an expression in VS Code's Debug Console and have the debug server evaluate it.

Now I wanted to colorize the result returned from an evaluate request. For example, error messages for an expression that cannot be evaluated should be printed in red.

The request is sent as this:

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "evaluate",
  "params": {
    "expression": "bad expression",
    "context": "repl"
  }
}

The response looks like this and contains ANSI escape codes to colorize the output:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "result": "\u001b[31mFailed to evaluate expresion\n...\u001b[0m",
    "variablesReference": 0
  }
}

However, the escape codes are ignored and the output in the Debug Console is like this:

[31mFailed to evaluate expression:
...[0m

Various issues have been opened asking VS Code to support ANSI escape codes or reporting color support as broken, some of them listed below

But all of them seem to be resolved.

Could anyone help me in finding the right response to have colored output in the Debug Console?

1

1 Answer 1

2

As it turns out, ANSI color codes are not interpreted when the result of an evaluation request is shown in the debug console.

If ANSI escape codes should be considered, they need to be sent through the output event.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.