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
can not output string with color in debug console after update to 1.22.1
Add ability to display high intensity ANSI colors in debug console
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?