Fix ReplaceAroundStep mapping when its from is zero #27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ocavue/map-replace-around"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR fixes a bug where
step.map(StepMap.offset(100))returnsnullunexpectedly ifstepis aReplaceAroundStepinstance andstep.fromis0.I added two tests to this PR. Only the first test can pass before the patch, and both tests can pass after the patch.
What use is a
ReplaceAroundStepwhen its gap has the same extent as its replaced range? What code is generating such steps?When I want to wrap a paragraph within a blockquote.
<p>foo</p>-><blockquote><p>foo</p><blockquote>Oh, duh, that actually makes sense for a wrapping step. So if a block is inserted at the start of the document, that'd move the start of the gap in front of the outer range and make the step invalid. But if this is a step that unwraps something or replaces a wrapping node, stuff concurrently inserted at the start of the gap should not be overwritten.
So I think a better logic here would be to map the old way if the gap edge isn't equal to the corresponding from/to, and invert it only when they are equal.
Thanks for your reply! I will try to add a test case for "a step that unwraps something or replaces a wrapping node" and modify the code as per your recommendation.
Sorry I couldn't find the correct test case to represent the scene in your previous comment. I updated the code as you described, although I don't understand why.
Merged your patches as
c625a131f6, followed up withef881296c2Thanks!
Pull request closed