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

Doubling group changes #1

Closed
brun0xon opened this issue Aug 3, 2020 · 2 comments
Closed

Doubling group changes #1

brun0xon opened this issue Aug 3, 2020 · 2 comments

Comments

@brun0xon
Copy link

brun0xon commented Aug 3, 2020

Hello. There is a bag:
My situation:

    var changes = ChangeStack();
    var a = 0;
    var change = Change.inline(() => a++, () => a--);

    changes.group();
    changes.add(change);
    print(a); // 1
    changes.add(change);
    print(a); // 2
    changes.commit();
    print(a); // 4

Situation in your example:

count = 0;

changes.group();

var increase = new Change.inline(() => count++, () => count--);
changes.add(increase);
changes.add(increase);

changes.commit();
print(count); // 2

changes.undo();
print(count); // 0

Plugin: undo 1.1.0+1

@rodydavis
Copy link
Owner

Fixed on 1.2.0, Refactored and should work as expected. There is a new interface but I updated the example and should be easier to use

@brun0xon
Copy link
Author

brun0xon commented Aug 3, 2020

Good!

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