Multiline changes are ignoring content hidden by replace decorations

Trying to understand a weird behavior with replace decorations. I have a document with a selection that spans multiple lines; edits to the document cause any content hidden a replace decoration to get lost.

Starting content:

Some text 
next line [replace decoration] more text

If I select the whitespace (including the newline) from text all the way to next, then press Space, for example:


Some text next line more text

Any keyboard input causes the content under the replace decoration to be entirely removed from the document.

The issue only seems to exist if the selection contains a newline and replace decorations appear anywhere on the last selected line.

Tracing the code and it looks like codemirror is resolving the document state with a mutation observer and trying to diff the new text in the document with the old state. But the DOMChange doesn’t seem to see any content hidden by Decorations.

Which browser and platform are you testing with? And does this happen with folded code or only with your own replace decorations?

I’m running into the problem on Electron (Chromium v124). I am able to repro with folded code, the document ends up with ... appended to it.

However, this might be something wrong with the setup since I’m not seeing the same behavior on the Codemirror sandbox. The content stays intact.

I’ll see if I can create a repro setup.