Create contextmanager for SimpleRevisionCommand

This commit is contained in:
David Vierra 2016-05-28 03:23:40 -10:00
parent 8d2d26fe3c
commit d2eb981e33

View File

@ -1001,6 +1001,16 @@ class EditorSession(QtCore.QObject):
finally:
self.pushCommand(command)
@contextmanager
def beginSimpleCommand(self, text):
command = SimpleRevisionCommand(self, text)
command.foo()
try:
with command.begin():
yield
finally:
self.pushCommand(command)
def pushCommand(self, command):
log.info("Pushing command %s" % command.text())
self.undoStack.push(command)