microsoft / monaco-editor

A browser based code editor
https://microsoft.github.io/monaco-editor/
MIT License
40.2k stars 3.58k forks source link

Decorations are not hidden within folded regions #3005

Open jmue opened 2 years ago

jmue commented 2 years ago

Reproducible in vscode.dev or in 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

-
hediet commented 2 years ago

Cannot reproduce:

recording

jmue commented 2 years ago

Sorry, after seeing this bug with Microsoft Webview2 and verifying with Monaco playground under Microsoft Edge I assumed this is a general bug. It turns out that the bug is only visible with Webview2 & Edge, not with Chrome or Firefox. monaco-3005 .

hediet commented 1 year ago

Now it always reproduces.

It would be very helpful if you could check if this reproduces in VS Code using extension API. If so, we can prioritize this issue.

chrome_raUJmh3KXK