From 0f27cd46ccadb2522babca5c5ab18ab26a3b5dbc Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 2 Oct 2020 09:41:29 -0700 Subject: [PATCH] Never render "Show More Context" inside an inline comment suggestion diff Summary: See PHI1896. If you do this: - Create an inline comment over a wide range of lines. - Suggest an edit. - Make a change near the beginning of the block. - Make a change near the end of the block. - Save the inline. ...you get a rendering which includes a "Show More Context" fold in the middle. Currently, this element renders in a visually broken way and consumes too many columns. However, this element isn't ever desirable inside inline comment suggestions. Stop it from rendering entirely. Test Plan: - Made an inline comment suggestion across lines 1-50 with edits at the beginning and end, saw a contiguous diff. - Made smaller inline comment suggestions (one line, a few lines). Differential Revision: https://secure.phabricator.com/D21476 --- .../diff/view/PHUIDiffInlineCommentDetailView.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php index fdaa99ac7e..3ff87c11ab 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php @@ -568,7 +568,24 @@ final class PHUIDiffInlineCommentDetailView $parser->setRenderer($renderer); - $diff_view = $parser->render(0, 0xFFFF, array()); + // See PHI1896. If a user leaves an inline on a very long range with + // suggestions at the beginning and end, we'll hide context in the middle + // by default. We don't want to do this in the context of an inline + // suggestion, so build a mask to force display of all lines. + + // (We don't know exactly how many lines the diff has, we just know that + // it can't have more lines than the old file plus the new file, so we're + // using that as an upper bound.) + + $min = 0; + + $old_len = count(phutil_split_lines($old_lines)); + $new_len = count(phutil_split_lines($new_lines)); + $max = ($old_len + $new_len); + + $mask = array_fill($min, ($max - $min), true); + + $diff_view = $parser->render($min, ($max - $min), $mask); $view = phutil_tag( 'div', -- 2.11.4.GIT