microsoft / microsoft/monaco-editor

[Bug] canBuildAST in BracketPairsTextModelPart affect language configuration

Open
#4,954 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bracket-pair-colorization bug
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

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
Image

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)
Image

Monaco Editor Playground Code

Reproduction Steps

No response

Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

No response

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.