monaco-editor
monaco-editor copied to clipboard
[Bug] `int` in Rust highlighted as a type
Reproducible in vscode.dev or in VS Code Desktop?
- [X] Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- [ ] Not reproducible in the monaco editor playground
Monaco Editor Playground Code
monaco.editor.create(document.getElementById('container'), {
value: "fn int() {}\nfn other() {}",
language: 'rust'
});
Actual Behavior
int highlighted as a type.
Expected Behavior
int not highlighted as a type.
Additional Context
No response
Generally set of keywords (and esp. typeKeywords) is a little surprising.
-
I cannot find any information about
proc,pure,alignof,offsetofandsizeofbeing a keyword. But I believe that in the past they were, and that's why they are in the list. -
The
typeKeywordscontains a list of type names fromlibccrate or some less-known crates (see:Eitherorm32) while missing types fromstdcrate (e.g.StringorVec) (Optiontype is in the list). I would limittypeKeywordsto primitive types +Self. Coloring non-std-and-non-primitive types as keywords may mislead somebody that some identifier is a keyword while it is not. -
The Rust language definition in Monaco also specifies folding markers:
#pragma regionand#pragma endregion. These are probably taken from C++, which supports#pragmadirectives. But Rust don't, and usage of#pragma regionin Rust code results in compilation errors.
The grammars are mostly community contributed. Feel free to create PRs to correct any mistakes. (in that case, please explain in detail your changes, so that not someone else creates a revert-PR)