microsoft / microsoft/monaco-editor
JavaScript folding ranges are not semantic
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
monaco-editor version: 0.20.0
Browser: Chrome
OS: Windows
Playground code that reproduces the issue:: https://microsoft.github.io/monaco-editor/playground.html#creating-the-editor-hello-world
Playground code
monaco.editor.create(document.getElementById("container"), {
value: "function double(x) {\nreturn 2*x\n}\n\nfunction double2(x) {\n\treturn 2*x;\n}",
language: "javascript",
showFoldingControls: "always",
});

I realized that the folding icon is hidden when all the lines of a Javascript function have no indentation. Using the same code but with tabs/spaces, the folding icon is shown.
In Visual Studio Code for Web Playground, I am also able to repro this issue.
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 the linked Monaco Editor playground in Chrome using the supplied JavaScript code, then compare folding behavior for the indented and non-indented function bodies. Trace the JavaScript folding-range behavior and make folding controls appear for function blocks regardless of indentation, while preserving the existing indented case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- developer-experience, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100