monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

[Bug] `int` in Rust highlighted as a type

Open chubei opened this issue 3 years ago • 2 comments

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?

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

chubei avatar May 31 '22 04:05 chubei

Generally set of keywords (and esp. typeKeywords) is a little surprising.

  1. I cannot find any information about proc, pure, alignof, offsetof and sizeof being a keyword. But I believe that in the past they were, and that's why they are in the list.

  2. The typeKeywords contains a list of type names from libc crate or some less-known crates (see: Either or m32) while missing types from std crate (e.g. String or Vec) (Option type is in the list). I would limit typeKeywords to 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.

  3. The Rust language definition in Monaco also specifies folding markers: #pragma region and #pragma endregion. These are probably taken from C++, which supports #pragma directives. But Rust don't, and usage of #pragma region in Rust code results in compilation errors.

wkordalski avatar Jun 21 '22 19:06 wkordalski

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)

hediet avatar Jul 19 '22 14:07 hediet