microsoft / microsoft/monaco-editor

Decorations are not hidden within folded regions

Open
#3,005 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug editor-core folding
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 Code
javascript:

monaco.languages.register({
	id: 'foldLanguage'
});

var value = `#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}

// Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
`;

const codeEditor = monaco.editor.create(document.getElementById('container'), {
	value: value,
	language: 'foldLanguage',

    automaticLayout: false,
    showFoldingControls: 'always',
    glyphMargin: true,
    wordWrap: 'on',
});

monaco.languages.registerFoldingRangeProvider('foldLanguage', {
	provideFoldingRanges: function (model, context, token) {
		return [
			// region1
			{
				start: 3,
				end: 6,
				kind: monaco.languages.FoldingRangeKind.Region
			}
		];
	}
});

codeEditor.deltaDecorations(
      [],
      [{
        range: new monaco.Range(5, 1, 5, 1),
        options: {
          stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
          glyphMarginClassName: 'red-dot',
          overviewRuler: { color: 'red', position: monaco.editor.OverviewRulerLane.Left },
          minimap: { color: 'red', position: monaco.editor.MinimapPosition.Inline },
          zIndex: 1
        }
      }]);

codeEditor.deltaDecorations(
      [],
      [{
        range: new monaco.Range(4, 14, 4, 14),
        options: {
          stickiness: monaco.editor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
          afterContentClassName: 'green-dot',
        }
      }]);

css:

.red-dot {
  background-color: red;
  border-radius: 50%;
  display: inline-block;
}

.green-dot {
  background-color: green;
  border-radius: 50%;
  width: 1em;
  height: 1em;
  display: inline-block;
}

html:

<div id="container" style="height: 100%"></div>


### Actual Behavior

Deltadecorations are not hidden within folded regions if 'wordWrap' is active and there are lines of code which are wrapped more than once.

Steps to reproduce: fold the region at line three, the red do at the glypth margin and the green dot within the text is still visible. If the comment on line eight is removed or 'wordWrap' is deactivated the red and green dot is hidden as well.

### Expected Behavior

Deltadecorations are always hidden within folded regions.

### Additional Context

-

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 Monaco Editor Playground reproduction, focusing on the registered folding range provider, the deltaDecorations calls, and wordWrap: 'on'. Reproduce the issue with the region folded and the long comment present. Done means glyph-margin and inline decorations inside the folded region are hidden when wrapped lines are present.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.