microsoft / microsoft/monaco-editor
[Bug] canBuildAST in BracketPairsTextModelPart affect language configuration
Nobody has claimed this yet.
- 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?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
I implement a custom language syntax support in vscode extension, which includes syntax highlight and language configuration feature. They works totally fine in vscode and vscode.dev.
When I try to implement it in monaco-editor with vscode-textmate, the syntax highlight works fine and language configuration setting does not work at all. After spending a day debugging, I find the class BracketPairsTextModelPart in esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsImpl.js might have some problems:
In contrary to monaco-editor(v0.21.2), monaco-editor(v0.52.2) adds a getter canBuildAST in class BracketPairsTextModelPart. As long as canBuildAST returns true, functions like matchBracket always return null because of new implementation branch(I need to debug deeper to find out why it returns null), while the old one works just fine for my language configuration setting
two branches that depend on canBuildAST
brackets match (I force canBuildAST to return false and the old branch runs)
brackets no match (I force canBuildAST to return true and the new branch runs , which is the bug)
Monaco Editor Playground Code
Reproduction Steps
No response
Actual (Problematic) Behavior
No response
Expected Behavior
No response
Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsImpl.js, focusing on BracketPairsTextModelPart.canBuildAST and the matchBracket branches it selects. Reconstruct the custom-language case described in the issue, since no playground code or reproduction steps are provided. Done means language configuration and bracket matching work for that case without forcing canBuildAST.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100