monaco editor matchBrackets do not highlight

Viewed 1826

I'm defining new language in . I expect that it automatically highlight matching brackets and parentheses because by default matchBrackets option is true.

Should I do anything else?

Sample Code: Look at this page it doesn't work in Microsoft's samples codes too.

1 Answers

You can see the original TypeScript source for the java language defined at:

https://github.com/microsoft/monaco-languages/blob/master/src/java/java.ts

The Compiled JavaScript looks like:

Language

If you see, what you need is not part of the language as such but part of the config of that language.

So If I open the console window on the Monarch demo link and execute below

config = {"surroundingPairs":[{"open":"{","close":"}"}],"autoClosingPairs":[{"open":"{","close":"}"}],"brackets":[["{","}"]]}
monaco.languages.setLanguageConfiguration("monarch-language-mylang", config)

The auto-matching of brackets starts working as shown below

config

Matching works

So you need to make sure to set the config as well for your language

Related