CodeMirror 6: widget decoration that takes up space

I need to make some kind of widget decorations that take up a character location in the editor, such that the cursor can sit at either side of the decoration. From what I tried, the widget can only take the cursor on one side but not the other. I also experimented with the replace decorations but they take up as many cursor positions as what they have replaced and I don’t want to actually insert anything. I just want a widget that takes up a character slot, so to speak.

I tried some experimenting with the PointDecoration class, but couldn’t find a way to make it work. Is this possible?

The way positions in the text are tracked uses document offsets, and as such, it isn’t possible to have two different cursor positions at a single document location (since the internal state couldn’t represent them).

Oh, okay. So I would probably need to insert a character and decorate that?

That would work, yes.

Alternatively, one could adjust keyboard navigation commands such that the decoration switches which side of the cursor it’s on and gives the appearance of taking up a character slot. That way the doc wouldn’t be muddied with the extra character.