You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Syntax highlighting for generic get methods inconsistent #4957
Describe the bug
Highlighting error: Generic get function is treated as keyword when proving the generic type.
To Reproduce
Take this code snippet:
voidmain() {
get();
get<int>();
}
voidget<T>() {}
Expected behavior
Having consistent highlighting that resembles a method instead of a keyword.
Screenshots
Please complete the following information:
You can run the Dart: Collect Diagnostic Information command from the VS Code command palette (F1) to easily capture this information or provide it manually.
Operating System and version: "Windows 10 Pro" 10.0 (Build 22635)
VS Code version: win 1.85.2
Dart extension version: 3.80.0
Dart/Flutter SDK version: 3.2.3/3.16.3
Target device (if the issue relates to Flutter debugging):
@icnahom could you confirm which theme you're using in VS Code, and what you have this setting set to?
The issue is likely in the textmate grammar, but if your theme supports it I would recommend using semantic tokens since the textmate grammar will never be as accurate or complete as semantic tokens.
@DanTup The theme I'm using is "GitHub Dark Default" from the Extension GitHub.github-vscode-theme.
When I enable semanticHighlighting "editor.semanticHighlighting.enabled": true, it works for the "get" issue I mentioned but messes up other codes' highlighting.
Broken highlighting, with "editor.semanticHighlighting.enabled": true.
Working highlighting, with "editor.semanticHighlighting.enabled": false.
Semantic tokens is the preferred way and the only way to get completely reliable highlighting (because it uses the real Dart parser). If things in your theme look bad with semantic tokens, it might be worth filing issues to try and get the theme updated.
The textmate grammar is much more basic and a best-effort. It uses regex and not a real Dart parser, so there will always be some things that aren't highlighted perfectly.
This case looks fairly simple though, so I'll see if it can be improved. The handling of get is a bit special because it can be both a keyword and a method name (and without a real parser, it's hard to know which).
Activity
DanTup commentedon Jan 24, 2024
@icnahom could you confirm which theme you're using in VS Code, and what you have this setting set to?
The issue is likely in the textmate grammar, but if your theme supports it I would recommend using semantic tokens since the textmate grammar will never be as accurate or complete as semantic tokens.
icnahom commentedon Jan 24, 2024
@DanTup The theme I'm using is "GitHub Dark Default" from the Extension
GitHub.github-vscode-theme.When I enable semanticHighlighting
"editor.semanticHighlighting.enabled": true, it works for the "get" issue I mentioned but messes up other codes' highlighting.Broken highlighting, with

"editor.semanticHighlighting.enabled": true.Working highlighting, with

"editor.semanticHighlighting.enabled": false.DanTup commentedon Jan 24, 2024
Thanks for the info.
Semantic tokens is the preferred way and the only way to get completely reliable highlighting (because it uses the real Dart parser). If things in your theme look bad with semantic tokens, it might be worth filing issues to try and get the theme updated.
The textmate grammar is much more basic and a best-effort. It uses regex and not a real Dart parser, so there will always be some things that aren't highlighted perfectly.
This case looks fairly simple though, so I'll see if it can be improved. The handling of
getis a bit special because it can be both a keyword and a method name (and without a real parser, it's hard to know which).Fix highlighting of generic methods named get/set
Fix highlighting of generic methods named get/set
Fix highlighting of generic methods named get/set (#57)