diff --git a/src/applications/differential/mail/DifferentialInlineCommentMailView.php b/src/applications/differential/mail/DifferentialInlineCommentMailView.php index 8b28b29c99..4c6dd5ea8b 100644 --- a/src/applications/differential/mail/DifferentialInlineCommentMailView.php +++ b/src/applications/differential/mail/DifferentialInlineCommentMailView.php @@ -290,9 +290,27 @@ final class DifferentialInlineCommentMailView $start = $comment->getLineNumber(); $length = $comment->getLineLength(); + // By default, show one line of context around the target inline. + $context = 1; + + // If the inline is at least 3 lines long, don't show any extra context. + if ($length >= 2) { + $context = 0; + } + + // If the inline is more than 7 lines long, only show the first 7 lines. + if ($length >= 6) { + $length = 6; + } + if (!$is_html) { $hunks = $changeset->getHunks(); - $patch = $parser->makeContextDiff($hunks, $is_new, $start, $length, 1); + $patch = $parser->makeContextDiff( + $hunks, + $is_new, + $start, + $length, + $context); $patch = phutil_split_lines($patch); // Remove the "@@ -x,y +u,v @@" line. @@ -318,7 +336,10 @@ final class DifferentialInlineCommentMailView $parser->setRenderer(new DifferentialChangesetOneUpMailRenderer()); - return $parser->render($start - 1, $length + 3, array()); + return $parser->render( + $start - $context, + $length + 1 + (2 * $context), + array()); } private function renderPatch( diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php index ef45896081..f7815538ac 100644 --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -852,7 +852,7 @@ final class DifferentialChangesetParser extends Phobject { $range_end = $this->getOffset($offset_map, $range_start + $range_len); $range_start = $this->getOffset($offset_map, $range_start); - $range_len = $range_end - $range_start; + $range_len = ($range_end - $range_start); } $render_pch = $this->shouldRenderPropertyChangeHeader($this->changeset); diff --git a/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php b/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php index ee1508d535..cb1fda70c6 100644 --- a/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php @@ -73,6 +73,8 @@ final class DifferentialChangesetOneUpMailRenderer } } + $style = "padding: 0 2px; {$style}"; + $out[] = phutil_tag( 'div', array(