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

[Bug] Language C highlights "class" as token

Open danieldietsch opened this issue 2 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 Link

Monaco Editor Playground Link

Monaco Editor Playground Code

const value = `typedef struct {
	xchar class;
} foo;`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "cpp",
});

Reproduction Steps

  1. Go to https://microsoft.github.io/monaco-editor/
  2. Select Language c
  3. Write
typedef struct {
    int class;
}

Actual (Problematic) Behavior

See that class is highlighted as keyword

Expected Behavior

class is no keyword in C, it should be highlighted like any other variable

Additional Context

No response

danieldietsch avatar Jun 23 '23 13:06 danieldietsch

It seems like not just "class" but all the keywords which where added in C++ but not present in C are highlighted as keyword. I looked into it and it seems there is no special file made for C language in basic languages folder. The keywords returned for .c extension is same as the ones returned for .cpp Take a look at this

os

What we can do is make a new folder for C language in basic languages.

ayushpatel-05 avatar Oct 04 '23 08:10 ayushpatel-05

Created PR to address this issue

SamiKamal avatar Dec 18 '23 18:12 SamiKamal