Don't repeat the diff property table when clicking "show more"

Summary:
If you "chmod +x" a file and then generate a diff and click "show 20 lines" on
that diff, you get another janky copy of the property table. Render the property
table only for top-level rendering requests.

This started happening after D409, which fixed the far-more-obvious bug of these
things never showing up. We must have changed the logic at some point since this
side effect was surprising to me. :P

Test Plan:
Created a diff with changes and +x, clicked "show 20 lines".

  - Original diff had file property header table thing, showing the +x.
  - New context brought in by "show 20 lines" didn't have it anymore.

Reviewed By: jungejason
Reviewers: aran, jungejason, tuomaspelkonen
CC: aran, epriestley, jungejason
Differential Revision: 482
This commit is contained in:
epriestley
2011-06-20 13:49:17 -07:00
parent 2330a1e954
commit 4a55af7857
2 changed files with 56 additions and 41 deletions

View File

@@ -54,6 +54,7 @@ class DifferentialChangesetParser {
private $isSubparser;
private $lineWidth = 80;
private $isTopLevel;
const CACHE_VERSION = 4;
@@ -831,6 +832,14 @@ EOSYNTHETIC;
$range_len = null,
$mask_force = array()) {
// "Top level" renders are initial requests for the whole file, versus
// requests for a specific range generated by clicking "show more". We
// generate property changes and "shield" UI elements only for toplevel
// requests.
$this->isTopLevel = (($range_start === null) && ($range_len === null));
$this->highlightEngine = new PhutilDefaultSyntaxHighlighterEngine();
$this->highlightEngine->setConfig(
'pygments.enabled',
@@ -894,7 +903,7 @@ EOSYNTHETIC;
}
$shield = null;
if ($range_start === null && $range_len === null && !$this->comments) {
if ($this->isTopLevel && !$this->comments) {
if ($this->isGenerated()) {
$shield = $this->renderShield(
"This file contains generated code, which does not normally need ".
@@ -1344,6 +1353,12 @@ EOSYNTHETIC;
}
protected function renderPropertyChangeHeader($changeset) {
if (!$this->isTopLevel) {
// We render properties only at top level; otherwise we get multiple
// copies of them when a user clicks "Show More".
return null;
}
$old = $changeset->getOldProperties();
$new = $changeset->getNewProperties();