Skip to content

Commit 033cae9

Browse files
committed
filediff: Dodge divide-by-zero in some edge cases
I'm not totally clear on when this happens, but in some cases (e.g., during slow file loading, when line revalidation is taking a while) we occasionally get lines with a height of zero. Since this adjustment exists mainly for smoother scrolling, it's easiest to just avoid the zero rather than doing anything complicated.
1 parent d6b8d24 commit 033cae9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

meld/filediff.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,8 @@ def _sync_vscroll(self, adjustment, master):
16741674
# Not doing this calculation makes scrolling jerky.
16751675
middle_iter, _ = self.textview[master].get_line_at_y(int(middle_y))
16761676
line_y, height = self.textview[master].get_line_yrange(middle_iter)
1677-
target_line = middle_iter.get_line() + ((middle_y-line_y)/height)
1677+
height = height or 1
1678+
target_line = middle_iter.get_line() + ((middle_y - line_y) / height)
16781679

16791680
# In the case of two pane scrolling, it's clear how to bind
16801681
# scrollbars: if the user moves the left pane, we move the

0 commit comments

Comments
 (0)