[meld] undo: Make our can undo/redo checks more defensive
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] undo: Make our can undo/redo checks more defensive
- Date: Sat, 10 Feb 2018 22:46:28 +0000 (UTC)
commit d4ac9b4f34f3e52c0984b3b4f2ef99b85ca61298
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Feb 11 08:14:50 2018 +1000
undo: Make our can undo/redo checks more defensive
This looks pointless, but it's about to be useful, I promise.
meld/undo.py | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/meld/undo.py b/meld/undo.py
index 8502eff3..fa634ff3 100644
--- a/meld/undo.py
+++ b/meld/undo.py
@@ -100,14 +100,13 @@ class UndoSequence(GObject.GObject):
self.checkpoints = {}
def can_undo(self):
- """Return if an undo is possible.
- """
- return self.next_redo > 0
+ """Return whether an undo is possible."""
+ return getattr(self, 'next_redo', 0) > 0
def can_redo(self):
- """Return if a redo is possible.
- """
- return self.next_redo < len(self.actions)
+ """Return whether a redo is possible."""
+ next_redo = getattr(self, 'next_redo', 0)
+ return next_redo < len(getattr(self, 'actions', []))
def add_action(self, action):
"""Add an action to the undo list.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]