microsoft / microsoft/monaco-editor

JavaScript folding ranges are not semantic

Open
#1,847 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request help wanted open for PR typescript
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",	
});

image

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.