[meld] filediff: Fix sync to scroll last line on to screen



commit 4d5df7aad0139a9d4cd96ebeae07c8906eb9ec8c
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Apr 25 11:48:51 2017 +1000

    filediff: Fix sync to scroll last line on to screen
    
    Because we're using exclusive end point for chunks, and because
    GtkTextBuffer will give you the last character on the last line if you
    ask for a point beyond the end of the buffer, we just add a simple
    "how far through my synced line am I" adjustment to handle scrolling
    the last line of a file into view.

 meld/filediff.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 8e4b6e5..cb5760e 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1725,7 +1725,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             other_line = obegin + fraction * (oend - obegin)
             it = self.textbuffer[i].get_iter_at_line(int(other_line))
             val, height = self.textview[i].get_line_yrange(it)
-            val += (other_line - int(other_line)) * height
+            # 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
             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]