From 91a229ae38f70bf96cb46b2a442f27b88fa6f6e6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Feb 2014 11:13:51 +0530 Subject: [PATCH] Compare books: Fix incorrect scrolling when viewing all text and a large amount of text is present after the final change. --- src/calibre/gui2/tweak_book/diff/view.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/calibre/gui2/tweak_book/diff/view.py b/src/calibre/gui2/tweak_book/diff/view.py index 6482ac84d3..6ac2ade4d8 100644 --- a/src/calibre/gui2/tweak_book/diff/view.py +++ b/src/calibre/gui2/tweak_book/diff/view.py @@ -940,7 +940,7 @@ def get_position_from_scrollbar(self, which): changes = self.changes[which] bar = self.bars[which] syncpos = self.syncpos + bar.value() - prev = (0, 0, None) + prev = 0 for i, (top, bot, kind) in enumerate(changes): if syncpos <= bot: if top <= syncpos: @@ -951,15 +951,14 @@ def get_position_from_scrollbar(self, which): ratio = 0 return 'in', i, ratio else: - # syncpos is after the change - offset = syncpos - prev[1] + # syncpos is after the previous change + offset = syncpos - prev return 'after', i - 1, offset - break else: - prev = (top, bot, kind) - else: - offset = syncpos - prev[1] - return 'after', len(self.changes) - 1, offset + # syncpos is after the current change + prev = bot + offset = syncpos - prev + return 'after', len(changes) - 1, offset def scroll_to(self, which, position): changes = self.changes[which]