Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground - Semantic token provider - SyntaxError: Invalid regular expression: invalid group specifier name #2459

Closed
JeanPerriault opened this issue Apr 28, 2021 · 1 comment

Comments

@JeanPerriault
Copy link
Contributor

Hello,
When opening https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-semantic-tokens-provider-example in Safari (version 14 or previous), I have this "SyntaxError: Invalid regular expression: invalid group specifier name" displayed in editor.

This seems linked to "Lookbehind in JS regular expressions", not supported in Safari.
https://caniuse.com/js-regexp-lookbehind

If replacing

const tokenPattern = new RegExp('(?<=\\[)([a-zA-Z]+)((?:\\.[a-zA-Z]+)*)(?=\\])', 'g');

with simpler

const tokenPattern = new RegExp('([a-zA-Z]+)((?:\\.[a-zA-Z]+)*)', 'g');

this works (at least in Chrome and Safari for macOS).

I could PR this but I'm not sure why brackets are used in original regex.

monaco-editor version: 0.23.0
Browser: Safari 14.1
OS: macOS Catalina 10.15.7

@hediet
Copy link
Member

hediet commented May 11, 2021

Thanks for pointing this out! That playground demo is an example, and in this particular implementation only text within brackets should be highlighted.

As this is not relevant for demoing the semantic tokenization, feel free to file a PR! We'd be happy to merge your fix.

@hediet hediet closed this as completed May 11, 2021
JeanPerriault added a commit to JeanPerriault/monaco-editor that referenced this issue May 19, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants