Insertion before change #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "insertion-fail"
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?
As described in https://github.com/ProseMirror/prosemirror-changeset/issues/6
Fixes an insertion before a change:
Thanks for looking into this.
The initial doc contains a paragraph with 10 characters in it, so including the paragraph start/end tokens, it's 12 tokens long, and 3-12 is a valid range.
I had, at one point, a fuzzer for this that found some bugs for which I created test cases. So these tests are machine generated, and while it's possible that the program that created them contained a bug, or that I transcribed them wrong, a failure might also well point at a real issue. I know they are terribly cryptic, but I'm worried that changing this one to make it pass might cover up a reintroduction of the bug that it originally caught.
Since the inner loop in
mergeis terribly subtle for zero-length changes, and your condition makes it even more tricky (and seems like the same issue might occur with the(inY && pos == curY.fromA)branch), would it maybe make sense to keepenteredXandenteredYvariables, which track whether we've already processedcurX.deletedandcurY.inserted? You'd have to clear them whencurXorcurYis updated, and set them in the appropriate branches. The result is probably easier to understand.Yes, it is valid but in this case incorrect :) My wording was perhaps badly chosen. The paragraph end token is not removed in the transaction, the end result of the fuzz test is as follows:
The part between
eAandfhas changed, i.e.[3, 10, 3, 10]. I think the bug as fixed in this pull request is also recorded by the fuzzer.Think so too, it's just hard to come up with a test that would cover this.
I'll try to do this and update the pull request later.
I've added your suggestions. The
inY && !inXandinX && !inYbranches both logically cannot be applied twice I believe, so they don't need the same treatment.Ah, I see—doing that replace will still preserve the end-of-paragraph token, so indeed, the actual generated step will have a different range and that test was confused.
Thanks for implementing this!