Why does @codemirror/selection use a separate layer?

I’m mostly just curious, why does the selection extension use an underlay instead of using decoration marks?

Depending on the answer, I’m also wondering if it’s worth considering having a layer abstraction that sort of mimic how decorations work but they use a separate layer instead of modifying the content dom, selections can be built on top of this. Obviously this can be created as a standalone package like the tooltip package.

Because the selection doesn’t just cover the text, but forms a rectangle all the way to the end of selected lines, and avoids gaps between lines and such.

This could probably be abstracted in a way that allows custom backdrop layers, yes, if a convincing use case is found. Would be hard not to obscure or be obscured by the selection though.

1 Like