microsoft / microsoft/monaco-editor
[Bug] editor.foldLevel1 does not fold first region if it's the first line
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
Here the first region does not collapse:
Adding a non-folding region beforehand (like a newline) fixes this:
Monaco Editor Playground Code
var editor = monaco.editor.create(document.getElementById("container"), {
value: `const hello = () => {
// This does not collapse
console.log("hello world");
}
const world = () => {
// This collapses
console.log("world, hello");
}`,
language: "javascript"
});
editor.getAction('editor.foldLevel1').run();
Reproduction Steps
View the sandbox, all level 1 regions should be folded automatically.
Actual (Problematic) Behavior
All regions are folded apart from the first one if that region is on the first line
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 by running the Monaco Editor Playground reproduction from the linked v0.52.2 examples and inspect the editor.foldLevel1 action with the provided JavaScript sample. Confirm the first level-1 region is skipped while later regions fold, then verify that the corrected behavior folds every level-1 region, including one beginning on the first line.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100