Skip to content
Snippets Groups Projects
Commit 9d0f53bac016 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

new undo_modification context manager on select nodes

parent 23ae480e4e43
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,13 @@
raise AssertionError('vref %r is not referenced (%r)' % (vref, vref.stmt))
return True
class undo_modification(object):
def __init__(self, select):
self.select = select
def __enter__(self):
self.select.save_state()
def __exit__(self):
self.select.recover()
class ScopeNode(BaseNode):
solutions = () # list of possibles solutions for used variables
......@@ -355,6 +362,9 @@
def should_register_op(self):
return self.memorizing and not self.undoing
def undo_modification(self):
return undo_modification(self)
def save_state(self):
"""save the current tree"""
self.undo_manager.push_state()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment