Skip to content
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

Add remove with a movement function #258

Open
mrkam2 opened this issue Mar 16, 2024 · 2 comments
Open

Add remove with a movement function #258

mrkam2 opened this issue Mar 16, 2024 · 2 comments

Comments

@mrkam2
Copy link

mrkam2 commented Mar 16, 2024

Problem/Opportunity
Sometimes it is hard to use remove because it always selects the previous node in a depth-first traversal. So after removing a selection may move arbitrarily deep in the tree structure. I propose to have an alternative version that applies a given traversal function so that you have better control over the selected node after the deletion.

Proposed Solution
(z/remove zloc z/left) selects the left sibling node after removing the current node.
(z/remove zloc z/right) selects the right sibling node after removing the current node.
(z/remove zloc z/prev) matches the current behavior.

Similar changes for z/remove* function.

@lread
Copy link
Collaborator

lread commented Mar 16, 2024

Thanks for raising this issue @mrkam2!

I agree remove can be tricky to use for the reason you described.

Your idea is interesting!

For (z/remove zloc z/left), I assume we'd throw when there is no left node?
And the same idea for (z/remove zloc z/right) when there is no right node?

@mrkam2
Copy link
Author

mrkam2 commented Mar 17, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants