private void RenderContext(Diff.Hunk hunk)
{
Range left = hunk.Left;
Range right = hunk.Right;
int displayed = 0;
if (Result.Length > 0) // not the first hunk, adding context for previous change
{
displayed = Math.Min(ContextLines, right.Count);
for (int i = 0; i < displayed; i++) ContextLine(right.Start + i);
}
int toDisplay = Math.Min(right.Count - displayed, ContextLines);
if ((left.End < LeftLines.Length - 1 || right.End < RightLines.Length - 1) && toDisplay > 0)
// not the last hunk, adding context for next change
{
if (right.Count > displayed + toDisplay)
{
ContextHeader(left.End - toDisplay + 1, right.End - toDisplay + 1);
}
for (int i = 0; i < toDisplay; i++)
{
ContextLine(right.End - toDisplay + i + 1);
}
}
}