-
Notifications
You must be signed in to change notification settings - Fork 4k
Monarch grammar: Regex starting with ^ should only match start of source line, but it does not. #1818
Description
monaco-editor version: 0.19.3
Browser: Chrome 79
OS: macOS
Playground code that reproduces the issue:
According to the Monarch docs:
If it starts with a
^character, the expression only matches at the start of a source line.
I have tried both specifying a regex literal /^!/ as well as a string "^!", but neither works.
You can reproduce the issue on the special Monarch playground at https://microsoft.github.io/monaco-editor/monarch.html. In the Language syntax definition, specify:
return {
// The main tokenizer for our languages
tokenizer: {
root: [
[/^\!/, {token: 'delimiter.curly', next: 'jsonInBang', nextEmbedded: 'json'}],
],
jsonInBang: [
[/^\!/, {token: 'delimiter.curly', next: '@pop', nextEmbedded: '@pop'}],
],
},
};And then in the Language editor, specify:
!
{
"foo": "bar",
"baz": 42,
"quux": [
{
"foo": "bar!",
}
],
"quux2": [
{
"foo": "bar",
}
]
}
!
If you look carefully, the JSON inside the ! starts out being highlighted correctly, but after the ! in the string literal "bar!", it stops working. It appears the /^\!/ has matched it even though it is not the start of a source code line, which is not what the docs claim should happen.