@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Pick context windows for inlines in a slightly smarter way

Summary:
Ref T10694. This mostly prevents us from having a degenerate case if someone leaves a 200-line inline.

- For one-line inlines, show 1 line of context above and below (3 lines total).
- For 3+ line inlines, show just the inline.
- For 7+ line inlines, show only the first part.

Test Plan: Made a bunch of weird long/short/different-sized comments, saw reasonble-appearing context in text and HTML mail output.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10694

Differential Revision: https://secure.phabricator.com/D15853

+26 -3
+23 -2
src/applications/differential/mail/DifferentialInlineCommentMailView.php
··· 290 290 $start = $comment->getLineNumber(); 291 291 $length = $comment->getLineLength(); 292 292 293 + // By default, show one line of context around the target inline. 294 + $context = 1; 295 + 296 + // If the inline is at least 3 lines long, don't show any extra context. 297 + if ($length >= 2) { 298 + $context = 0; 299 + } 300 + 301 + // If the inline is more than 7 lines long, only show the first 7 lines. 302 + if ($length >= 6) { 303 + $length = 6; 304 + } 305 + 293 306 if (!$is_html) { 294 307 $hunks = $changeset->getHunks(); 295 - $patch = $parser->makeContextDiff($hunks, $is_new, $start, $length, 1); 308 + $patch = $parser->makeContextDiff( 309 + $hunks, 310 + $is_new, 311 + $start, 312 + $length, 313 + $context); 296 314 $patch = phutil_split_lines($patch); 297 315 298 316 // Remove the "@@ -x,y +u,v @@" line. ··· 318 336 319 337 $parser->setRenderer(new DifferentialChangesetOneUpMailRenderer()); 320 338 321 - return $parser->render($start - 1, $length + 3, array()); 339 + return $parser->render( 340 + $start - $context, 341 + $length + 1 + (2 * $context), 342 + array()); 322 343 } 323 344 324 345 private function renderPatch(
+1 -1
src/applications/differential/parser/DifferentialChangesetParser.php
··· 852 852 853 853 $range_end = $this->getOffset($offset_map, $range_start + $range_len); 854 854 $range_start = $this->getOffset($offset_map, $range_start); 855 - $range_len = $range_end - $range_start; 855 + $range_len = ($range_end - $range_start); 856 856 } 857 857 858 858 $render_pch = $this->shouldRenderPropertyChangeHeader($this->changeset);
+2
src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php
··· 73 73 } 74 74 } 75 75 76 + $style = "padding: 0 2px; {$style}"; 77 + 76 78 $out[] = phutil_tag( 77 79 'div', 78 80 array(