microsoft / microsoft/monaco-editor

[Bug] Incorrect syntax highlighting of Perl regex string

Open
#4,165 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted languages-basic
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.41.0#XQAAAAJGAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzPYGRgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugtAtrZZl00gBtQ18GrD0DOEiukzBVguDDmDX0oDR0pbCK0JNW3wlzPpgDoOYFvE5HbmEwFq8ZBVlbrwj5M3U91pgpasFYsomPXmsFfzUy1pUsnf-Jdmt1Jb68B9zkz7gfrevYd8HIa_II2BKE8V-dbXVHIGNLgqWBXGR7HOoE5TEEm0SgAMw0TWrgXRI0mnJxrMF3yP_bgKxNkSIVTpsM6D7fuwaus

Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `my \$regex = qr{\\W{1,10}}`;

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

Put the editor in Perl mode, type in my $regex = qr{\\W{1,10}}

Actual (Problematic) Behavior

The regular expression was interpreted as being closed by the first instance of } resulting in the second instance being highlighted red. See below:
image

Expected Behavior

The regular expression string should continue to be highlighted up to and including the second } as show in the vscode.dev screenshot below.

Additional Context

Correct syntax highlighting on vscode.dev:
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Monaco Editor Playground, using the supplied TypeScript setup in Perl mode and the my $regex = qr{\\W{1,10}} example. Compare the highlighting around both closing braces with the expected vscode.dev behavior; done means the full regex remains highlighted through the second }.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl, typescript
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.