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

Trouble combining Splitter with Undo/Redo #742

Closed
merlerm opened this issue Feb 14, 2022 · 2 comments
Closed

Trouble combining Splitter with Undo/Redo #742

merlerm opened this issue Feb 14, 2022 · 2 comments

Comments

@merlerm
Copy link

merlerm commented Feb 14, 2022

Hello,
I'm currently having troubles implementing the Splitter interaction with the Undo/Redo interaction.
I suspect this is because under the hood the splitter is cloning features and adds unwanted undoable interactions on the stack after every split and this invalidates the entire stack.
For example, when crossing two straight lines I get 8 additional undo "addfeature" actions added to the stack.
Is there any way to implement this or filter out interactions coming from the splitter? I would like to keep the splitter but also be able to undo the last line drawn using the undo feature.
Thanks for your time, sorry if this is not the place to ask these types of question.

@Viglino
Copy link
Owner

Viglino commented Feb 14, 2022

The trouble with the Splitter interaction is it performs a set of creation / destruction after the action on the feature.
I've tried to take it into account in the last commit to make a single action that groups the action on the feature and the split.
This should work now.

Be aware that the Splitter interaction must not be active when undoing / redoing or it will try to split features while undoing.
You have to deactivate it before undo:

splitter.setActive(false);
undo.undo();
splitter.setActive(true);

@merlerm
Copy link
Author

merlerm commented Feb 14, 2022

Thanks for the quick reply and swift fix, it seems to work perfectly for now! Keep up the good work ^^

@Viglino Viglino closed this as completed Feb 25, 2022
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