-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix move_node behaviour in PathUtils.transform #2871
Conversation
@themithy thanks for this. Can you remove the |
Hi @ianstormtaylor! First of all, thanks for the awesome tool! As for the Let's take the @themithy's example. We have 2 nodes at paths So if we were to transform the path Now, how will the [*] - getting back. I want to explain my thinking here in case you disagree. When working with Slate's operations I always assume that when inserting at a path Sorry for the lengthy explanation, hope this clarifies the fix a bit. |
@justinweiss could you double check this one? I can't remember what we decided on |
Here's the discussion we had before: #2192 Like I said in there, I'm on a much older version, so this may not still be accurate. But the way I understood it, if you have:
The
So I think this is what you might expect, but doesn't match the way that Slate actually performs |
This is very interesting, I did not consider that interpretation of how a If I have a at [0] and b at [1], and I say "move [0] to [1]", my gut tells me that I should have "ba". It also seems foreign to say that I need to "move [0] to [2]" in order to achieve that effect, since there is presently no [2] and there will be no [2] after the operation either. I am also a little uncomfortable with the notion that "move p to np" should be a no-op where p != np. However, I do see that there are advantages to having a hard rule that a node is always inserted before a node that exists at |
If I am reading this correctly, the way the old code functioned was that [0] -> [1] represented a swap: |
Fixed by #3093. |
Hi,
We have a fix for two bugs in move_node in path transform. The problem is that in some cases the path does not get transformed correctly, which leads to assertions being thrown.
The first bug exists because the check against
op.newPath
is done after the transformation againstop.path
. This leads to unexpected behaviour in scenario that the path is transformed in such a way that the second check matches, but should not.The second problem is the check against path size which should be
<=
and not<
in our opinion. After this fix, some test cases begin to throw, but this is because what we believe there is a problem in those testcases. If we have two siblings [0] and [1], and move the first to the path [1], the item should not move at all, because path [1] is before the second element. That is how we understand this, but however please confirm this finding.Thanks in advance for reviewing it.