-
Notifications
You must be signed in to change notification settings - Fork 95
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
Move node to first position #324
Comments
Did you try this method? It should accept the empty On the other hand, the method that is given a parent will do consistency checks. Maybe you're using this second method where you actually wanted the first? |
Thank you for your quick reply, if I use this method, it will call Line 985 in 74c8031
has_sibling checks, which fail for the NodeRef{tree, NONE} node, because it isn't part of the tree. Or are there other ways to create/get this pseudo NodeRef?
|
Ah, got it. This is a bug indeed. But maybe you can work around it for now. Looking at this line: Line 989 in 74c8031
It seems that the assert there is not exactly right, and should accomodate _RYML_CB_ASSERT(m_callbacks, (after == NONE) || (has_sibling(node, after) && has_sibling(after, node))); what happens? Let me know if it works. Or worst case, you can just call those functions on your own: void mymove(Tree &tree, size_t node, size_t after)
{
tree._rem_hierarchy(node);
tree._set_hierarchy(node, tree.parent(node), after);
} (I will fix it on my own anyway and add proper unit tests, but for now it's just hard to get the time to look at it; the suggestions above are just to get you going quicker.) |
By the way, Line 631 in 74c8031
|
Right, I think there needs to be a check if it is NONE or not. I can't call Btw. right now I'm working around this issue by
|
@a-w50 I prepared a PR, and improved the tests to address this scenario as well. The tests pass on my PC, but let's wait for the whole suite to finish in the CI. FWIW, you can move the subject node to the first position within its parent by simply doing subject.move({}); And if the parent is a different one, either on the same or on a different tree: subject.move(new_parent, {}); |
👍 |
Hi,
is it possible to use the node
move
operation in order to move a node along it's siblings to the first place? Right now, there is only anafter
option. Using a NodeRef {tree, c4::yml::NONE } as after, doesn't seem to work, as it is not a sibling.Thanks for this library!
The text was updated successfully, but these errors were encountered: