From 37298824edbfb0c5123d9cf9d6fb46991aad9343 Mon Sep 17 00:00:00 2001
From: "James E. Blair" <jeblair@linux.vnet.ibm.com>
Date: Wed, 6 Jan 2016 14:16:30 -0800
Subject: [PATCH] Correct display of comments at start of file

Due to a math error, comments at the start of the file when outside
of the diff context may have not been displayed.  This corrects
the error.

Change-Id: Ic879d3c434faaa5d884547889a602a7157d1b2a8
---
 gertty/view/diff.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gertty/view/diff.py b/gertty/view/diff.py
index 7861f55..6a12e67 100644
--- a/gertty/view/diff.py
+++ b/gertty/view/diff.py
@@ -303,6 +303,7 @@ class BaseDiffView(urwid.WidgetWrap):
                         lines += self.makeLines(diff, chunk.lines[-10:], comment_lists)
                         del chunk.lines[-10:]
                     chunk.calcRange()
+                    chunk.button.update()
                     if not chunk.lines:
                         lines.remove(button)
                 else:
@@ -352,7 +353,7 @@ class BaseDiffView(urwid.WidgetWrap):
                     if from_start:
                         self.expandChunk(diff, chunk, comment_lists, from_start=i+10)
                     else:
-                        self.expandChunk(diff, chunk, comment_lists, from_end=i-10)
+                        self.expandChunk(diff, chunk, comment_lists, from_end=0-(len(chunk.lines)-i)-10)
                     break
 
     def expandChunk(self, diff, chunk, comment_lists={}, from_start=None, from_end=None,