Weird reverse selection on decorated nodes

In the case when we decorate a node with a widget-decoration and then start a selection by keyboard from last node position, it behaves correct in the forward selection but weird when you select back.

Untitled

This is what the DOM looks like: 35

Prosemirror considers the line break (widget-decoration) to be an ignorable node and resets the selection inside skipIgnoredNodesLeft.

How can I prevent the resetting of the selection during reverse selection? Or maybe the new selection is just wrong?

I tried adding a widget decoration at the end of a paragraph and selecting through it with shift-left-arrow in both Firefox and Chrome, but I’m not seeing anything odd happen. Could you describe more precisely what you’re doing?

I’ve uploaded an example project on Glitch

Steps to reproduce on Google Chrome:

  • Position your cursor on the end of line 1 (after tempor)
  • Hit shift-down-arrow twice
  • Hit shift-up-arrow

Now the first paragraph is selected, which I think is wrong.

It’d be nice if you could reduce your test case a little more next time—I wasted 10 minutes throwing out irrelevant code until I was left with a 20-line plugin. But I did find a bug, and fixed it in this patch.