[meld] Fix scrollbar position reset after merge actions



commit 86bf5d50fb0183a257399896072c21c696ce44ec
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Jun 19 09:04:24 2010 +1000

    Fix scrollbar position reset after merge actions
    
    The previous code attempted to reset the scrollbar position, but was
    foiled by the immediate _sync_vscroll after setting the new text. We
    fix this here by taking the vscroll lock before setting the new text.

 meld/filediff.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 6ace2d5..df966b1 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -338,10 +338,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         merger.texts = [t for t in self._get_texts(raw=1)]
         for mergedfile in merger.merge_2_files(src, dst):
             pass
+        self._sync_vscroll_lock = True
         self.on_textbuffer__begin_user_action()
         self.textbuffer[dst].set_text(mergedfile)
         self.on_textbuffer__end_user_action()
-        self.scheduler.add_task( lambda : self._sync_vscroll( self.scrolledwindow[src].get_vadjustment(), src ) and None )
+        def resync():
+            self._sync_vscroll_lock = False
+            self._sync_vscroll(self.scrolledwindow[src].get_vadjustment(), src)
+        self.scheduler.add_task(resync)
 
     def merge_all_non_conflicting_changes(self):
         dst = 1
@@ -350,10 +354,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         merger.texts = [t for t in self._get_texts(raw=1)]
         for mergedfile in merger.merge_3_files(False):
             pass
+        self._sync_vscroll_lock = True
         self.on_textbuffer__begin_user_action()
         self.textbuffer[dst].set_text(mergedfile)
         self.on_textbuffer__end_user_action()
-        self.scheduler.add_task( lambda : self._sync_vscroll( self.scrolledwindow[0].get_vadjustment(), 0 ) and None )
+        def resync():
+            self._sync_vscroll_lock = False
+            self._sync_vscroll(self.scrolledwindow[0].get_vadjustment(), 0)
+        self.scheduler.add_task(resync)
 
     def delete_change(self, widget):
         pane = self._get_focused_pane()



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