[meld] Add a clear() method to Differ to avoid manually emptying diffs



commit c0c27cf888a29f94e6336648ffbebe42d1ebf26b
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Mar 12 15:08:03 2010 +1000

    Add a clear() method to Differ to avoid manually emptying diffs
    
    Previously we reset Differ manually, but this left it in an inconsistent
    state. This inconsistency doesn't show up currently, but it was easy to
    hit problems when trying to be more relaxed about painting custom
    widgets.

 meld/diffutil.py |    5 +++++
 meld/filediff.py |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/meld/diffutil.py b/meld/diffutil.py
index 9109855..074b386 100644
--- a/meld/diffutil.py
+++ b/meld/diffutil.py
@@ -369,3 +369,8 @@ class Differ(object):
         self._update_merge_cache(sequences)
         yield 1
 
+    def clear(self):
+        self.diffs = [[], []]
+        self.seqlength = [0] * self.num_sequences
+        texts = [""] * self.num_sequences
+        self._update_merge_cache(texts)
diff --git a/meld/filediff.py b/meld/filediff.py
index 3507c14..8b6dd67 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -667,7 +667,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         yield _("[%s] Set num panes") % self.label_text
         self.set_num_panes( len(files) )
         self._disconnect_buffer_handlers()
-        self.linediffer.diffs = [[],[]]
+        self.linediffer.clear()
         self.queue_draw()
         try_codecs = self.prefs.text_codecs.split() or ['utf_8', 'utf_16']
         yield _("[%s] Opening files") % self.label_text



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]