Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Syntax highlighting does not support new %w specifier for wrapped errors #2819

Closed
wtask opened this issue Oct 7, 2019 · 6 comments
Closed
Labels
upstream upstream-grammar Issue is related to the grammar used for Go which is controlled upstream in VS Code project

Comments

@wtask
Copy link

wtask commented Oct 7, 2019

New Go format specifier %w, introduced with Go 1.13 to support error wrapping is not supported by syntax highlighter

@dhowden
Copy link
Contributor

dhowden commented Oct 8, 2019

I've been wanting to try and fix this for a while, but failed to find the relevant TextMate grammar file in this repo. I think it's probably in the main release of VSCode, particularly as syntax highlighting is available before the extension is installed.

@dhowden
Copy link
Contributor

dhowden commented Oct 9, 2019

Following up, the file is here: https://github.com/microsoft/vscode/blob/master/extensions/go/syntaxes/go.tmLanguage.json

Apparently it's copied from: https://github.com/atom/language-go/blob/master/grammars/go.cson and changes should be made there, have make a pull request, so let's see what happens!

@dhowden
Copy link
Contributor

dhowden commented Oct 11, 2019

So looks like this isn't going to happen soon. My pull request was closed because Atom are migrating to another syntax system. The VSCode syntax is a fork of the Atom one, and they don't accept pull requests (turns out someone else had a crack at this already): microsoft/vscode#81015

@wtask
Copy link
Author

wtask commented Oct 11, 2019

Will have to wait, thank you

@ramya-rao-a
Copy link
Contributor

@dhowden is right.

The colors are controlled by the grammar being used and the grammar is part of the main VS Code project. Therefore, please log this issue in the VS Code repo

Also, please note that we can't possibly have different grammars being used for different versions of Go. So any solution put in place here will be applied for any Go file regardless of the Go version being used.

@ramya-rao-a ramya-rao-a added upstream-grammar Issue is related to the grammar used for Go which is controlled upstream in VS Code project upstream labels Oct 14, 2019
@flowchartsman
Copy link

flowchartsman commented Oct 15, 2019

For posterity, I've submitted an issue here. Who knows how long it will take, but in the meantime you can hack it into VScode yourself. The relevant syntax is buried somewhere in extensions/go/syntaxes/go.tmLanguage.json Look for the following in the definition of string_placeholder:

[vT%tbcdoqxXUbeEfFgGsp]

and simply tack on a w after the p. And then do that for every release ever until it's fixed. :-\

As to the issue of older versions erroneously highlighting %w, I think that's probably a small price to pay for compatibility moving forward.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream upstream-grammar Issue is related to the grammar used for Go which is controlled upstream in VS Code project
Projects
None yet
Development

No branches or pull requests

4 participants