Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/diff/PhabricatorDocumentEngineBlocks.php
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public function newTwoUpLayout() { | ||||
$count = count($old_lines); | $count = count($old_lines); | ||||
for ($ii = 0; $ii < $count; $ii++) { | for ($ii = 0; $ii < $count; $ii++) { | ||||
$old_line = idx($old_lines, $ii); | $old_line = idx($old_lines, $ii); | ||||
$new_line = idx($new_lines, $ii); | $new_line = idx($new_lines, $ii); | ||||
if ($old_line) { | if ($old_line) { | ||||
$old_hash = rtrim($old_line['text'], "\n"); | $old_hash = rtrim($old_line['text'], "\n"); | ||||
if (!strlen($old_hash)) { | |||||
// This can happen when one of the sources has no blocks. | |||||
$old_block = null; | |||||
} else { | |||||
$old_block = array_shift($old_map[$old_hash]); | $old_block = array_shift($old_map[$old_hash]); | ||||
$old_block->setDifferenceType($old_line['type']); | $old_block->setDifferenceType($old_line['type']); | ||||
} | |||||
} else { | } else { | ||||
$old_block = null; | $old_block = null; | ||||
} | } | ||||
if ($new_line) { | if ($new_line) { | ||||
$new_hash = rtrim($new_line['text'], "\n"); | $new_hash = rtrim($new_line['text'], "\n"); | ||||
if (!strlen($new_hash)) { | |||||
$new_block = null; | |||||
} else { | |||||
$new_block = array_shift($new_map[$new_hash]); | $new_block = array_shift($new_map[$new_hash]); | ||||
$new_block->setDifferenceType($new_line['type']); | $new_block->setDifferenceType($new_line['type']); | ||||
} | |||||
} else { | } else { | ||||
$new_block = null; | $new_block = null; | ||||
} | } | ||||
// If both lists are empty, we may generate a row which has two empty | |||||
// blocks. | |||||
if (!$old_block && !$new_block) { | |||||
continue; | |||||
} | |||||
$rows[] = array( | $rows[] = array( | ||||
$old_block, | $old_block, | ||||
$new_block, | $new_block, | ||||
); | ); | ||||
} | } | ||||
return $rows; | return $rows; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |