HigherOrderCO / bend-language-server

Language server for the Bend programming language
MIT License
7 stars 2 forks source link

Diagnostic highlighting #1

Open edusporto opened 1 month ago

edusporto commented 1 month ago

The Bend compiler already allows highlighting of diagnostic reporting through ANSI color escape codes - however, we're still not able to send highlighted messages to VSCode since it does not implement it yet.

Once Microsoft/vscode#54272 is closed/merged, we will be able to easily implement this using a library like ansi_to_html.

developedby commented 1 month ago

Does it know how to handle (properly ignore) color escape codes? If not, we can easily remove all of them from the language server diagnostics with a simple regex.

I wouldn't count on any external tool in particular implementing this. These things can be quite slow and are out of our control.

edusporto commented 1 month ago

Does it know how to handle (properly ignore) color escape codes?

Not really, VSCode just prints the color escape codes as if they were in a raw string. Right now I'm implementing the regex you mentioned to remove these color codes in the language server's side.

Another way to deal with this would be to implement some sort of "is terminal?" check in the Bend compiler and avoid printing the color codes if it is not, like many other compilers do, and add a flag to force color printing if needed. Considering TSPL already prints messages with the color codes, I imagine the team would prefer the first solution I mentioned.