CodeMirror 6: Decorations during typing

Hi @marijn, do you happen to have an example of using Decorations that update while the user is typing: typing within a Decoration increments its “to” offset, typing before a decoration increments its “from” offset. I’m guessing using the RangeSet mapping functionality will be necessary but it isn’t immediately obvious to me how to do that.

You can map decoration sets through changes with their map method. So for decorations that persist through changes, you’d store them in a state field and, in that field’s update function, map them through any document changes.

Thanks @marijn. That turned out to be easier than I had anticipated. Seems to be working well.