[meld: 4/5] filediff: Fix scroll syncing to include overscroll as a factor



commit a1ab7b24447f3826108468aa465eac687c630376
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Nov 3 06:09:20 2019 +1000

    filediff: Fix scroll syncing to include overscroll as a factor

 meld/filediff.py | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 6d56fe4b..9a08ed93 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -2128,11 +2128,20 @@ class FileDiff(Gtk.VBox, MeldDoc):
 
             fraction = (target_line - mbegin) / ((mend - mbegin) or 1)
             other_line = obegin + fraction * (oend - obegin)
+
+            # At this point, we've identified the line within the
+            # corresponding chunk that we want to sync to.
             it = self.textbuffer[i].get_iter_at_line(int(other_line))
             val, height = self.textview[i].get_line_yrange(it)
             # Special case line-height adjustment for EOF
             line_factor = 1.0 if it.is_end() else other_line - int(other_line)
             val += line_factor * height
+            if syncpoint > 0.5:
+                # If we're in the last half page, gradually factor in
+                # the overscroll margin.
+                overscroll_scale = (syncpoint - 0.5) / 0.5
+                overscroll_height = self.textview[i].get_bottom_margin()
+                val += overscroll_height * overscroll_scale
             val -= adj.get_page_size() * syncpoint
             val = min(max(val, adj.get_lower()),
                       adj.get_upper() - adj.get_page_size())


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