Use root-constrained filter when counting distance to the anchor node
Constrain both the anchor and cursor nodes when fixing cursor positions after an operation

Adjustments to the cursor position when near paragraph boundaries was causing
the selection length to incorrectly change, or the anchor to skip to the
following paragraph (see added tests).

Now, both the anchor and cursor are treated identically when "fixing" the
cursor selection after a document modification.