@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.

Recover inline comments which are "adjusted" off the end of a diff

Summary:
See PHI1834. Currently, the inline adjustment engine can sometime "adjust" an inline off the end of a diff. If it does, we lay it out on an invalid display line here and never render it.

Instead, make sure that layout never puts a comment on an invalid line, so the UI is robust against questionable decisions by the adjustment engine: no adjustment should be able to accidentally discard an inline.

Test Plan:
- Created a two diff revision, where Diffs 1 and 2 have "alphabet.txt" with A-Z on one line each. The file is unchanged across diffs; some other file is changed.
- Added a comment to lines P-Z of Diff 1.
- Before: comment is adjusted out of range on Diff 2 and not shown in the UI.
- After: comment is still adjusted out of range internally, but now corrected into the display range and shown.

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

+21 -5
+21 -5
src/applications/differential/parser/DifferentialChangesetParser.php
··· 1053 1053 $this->comments = id(new PHUIDiffInlineThreader()) 1054 1054 ->reorderAndThreadCommments($this->comments); 1055 1055 1056 + $old_max_display = 1; 1057 + foreach ($this->old as $old) { 1058 + if (isset($old['line'])) { 1059 + $old_max_display = $old['line']; 1060 + } 1061 + } 1062 + 1063 + $new_max_display = 1; 1064 + foreach ($this->new as $new) { 1065 + if (isset($new['line'])) { 1066 + $new_max_display = $new['line']; 1067 + } 1068 + } 1069 + 1056 1070 foreach ($this->comments as $comment) { 1057 - $final = $comment->getLineNumber() + 1058 - $comment->getLineLength(); 1059 - $final = max(1, $final); 1071 + $display_line = $comment->getLineNumber() + $comment->getLineLength(); 1072 + $display_line = max(1, $display_line); 1073 + 1060 1074 if ($this->isCommentOnRightSideWhenDisplayed($comment)) { 1061 - $new_comments[$final][] = $comment; 1075 + $display_line = min($new_max_display, $display_line); 1076 + $new_comments[$display_line][] = $comment; 1062 1077 } else { 1063 - $old_comments[$final][] = $comment; 1078 + $display_line = min($old_max_display, $display_line); 1079 + $old_comments[$display_line][] = $comment; 1064 1080 } 1065 1081 } 1066 1082 }