Open davidscherer opened 4 years ago
@alexdima I can confirm that weird playground bug
In another example https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-listening-to-mouse-events adding new line and folding a block of code causing view zone displacement
monaco-editor version: 0.20.0 Browser: Firefox, Chromium OS: Linux Playground code that reproduces the issue:
Any time a view zone is moved to a different absolute line number by text flow, and then something happens anywhere in the document that triggers
ViewZones._recomputeWhitespaceProps()
, the view zone winds up in the wrong place.You can also get this to happen in VS Code in a somewhat convoluted way:
The problem seems to be that
ViewZones._recomputeWhitespaceProps()
callsViewZones._computeWhitespaceProps()
which looks atIViewZone.afterLineNumber
and expects it to be up to date. This is a reasonable assumption for the other callers of_computeWhitespaceProps
, which are only called when adding or changing the layout of a zone, when the creator of theViewZone
is specifying a point in the file to insert the zone. But it is not reasonable at an arbitrary time later, when text flow may have moved theViewZone
to a different absolute line number but there is no obvious way to updateafterLineNumber
accordingly.I assume that _recomputeWhitespaceProps() exists for a reason, but when I stub it out with "return false" it seems to solve this problem. I can't propose a specific fix without better understanding what the function is trying to do.