editor: Add basic undo command.

This commit is contained in:
Andrew Hamilton 2022-01-13 00:51:04 +10:00
parent ea1f729b06
commit bc32e358a1
3 changed files with 21 additions and 1 deletions

View file

@ -218,6 +218,15 @@ class EditorTestCase(unittest.TestCase):
self.editor.cursor_down()
self._assert_change(self.editor.comment_lines, "ab# c\n# def\n# gh\ni\njkl", (4, 2))
def test_undo(self):
self._set_editor("ab", (1, 0))
self.editor.add_to_history()
self.editor.enter()
self.editor.add_to_history()
self.editor.enter()
self._assert_change(self.editor.undo, "a\nb", (0, 1))
self._assert_change(self.editor.undo, "ab", (1, 0))
if __name__ == "__main__":
unittest.main()