EvgeniyPeshkov / syntax-highlighter

Syntax Highlighter extension for Visual Studio Code (VSCode). Based on Tree-sitter.
https://marketplace.visualstudio.com/items?itemName=evgeniypeshkov.syntax-highlighter
MIT License
210 stars 43 forks source link

[C++] Virtual function oddities #23

Closed bbatliner closed 5 years ago

bbatliner commented 5 years ago

I can't explain what's going on here: the highlighting changes vastly despite the function signatures being nearly identical. The presence of the virtual keyword seems to play an effect. In this example, the first function has incorrect/inconsistent highlighting, and the second is highlighted as expected.

image

bbatliner commented 5 years ago

I think adding virtual as a modifier will solve this issue. I don't see it in the cpp grammar. I'll make a PR on Github but I can't really test it.

EvgeniyPeshkov commented 5 years ago

Hello @bbatliner , In fact it's a bug in tree-sitter-cpp, that incorrectly parses definitions with virtual. I've just discovered, that there's a newer version, maybe it's already fixed. Otherwise I'll upstream corresponding question to tree-sitter-cpp developers. Anyway, there's another bug with default. Yet you are right that virtual is missing. I'll merge your PR. Please note, that it won't fix the issue.

EvgeniyPeshkov commented 5 years ago

Hello @bbatliner , It seems I was right, the latest version of tree-sitter-cpp fixes at least this issue. I'll publish a new version in a day. Stay tuned. image

bbatliner commented 5 years ago

Awesome, that's great to hear. It looks like throw and maybe __attribute__ got added to that latest version, as well. We might be able to close #21, if it fixes that, too.

EvgeniyPeshkov commented 5 years ago

throw and virtual have been fixed indeed. But highlighting of structs with __attribute__ is still corrupted, it became slightly better though. It seems, that attributes are fixed only for functions in tree-sitter-cpp. So let's leave #21 open for a while. I'll try to ask tree-sitter-cpp developers to fix this issues.

EvgeniyPeshkov commented 5 years ago

Hello @bbatliner , just in case, this bug is fixed in the latest version 0.3.3, I've published on Friday.

bbatliner commented 5 years ago

Yes, confirmed. Thanks.