Changeset View
Changeset View
Standalone View
Standalone View
src/utils/PhutilProseDifferenceEngine.php
Show All 19 Lines | private function buildDiff(PhutilProseDiff $diff, $u, $v, $level) { | ||||
$u_parts = $this->splitCorpus($u, $level); | $u_parts = $this->splitCorpus($u, $level); | ||||
$v_parts = $this->splitCorpus($v, $level); | $v_parts = $this->splitCorpus($v, $level); | ||||
$matrix = id(new PhutilEditDistanceMatrix()) | $matrix = id(new PhutilEditDistanceMatrix()) | ||||
->setSequences($u_parts, $v_parts) | ->setSequences($u_parts, $v_parts) | ||||
->setComputeString(true); | ->setComputeString(true); | ||||
// For word-level and character-level changes, smooth the output string | |||||
// to reduce the choppiness of the diff. | |||||
if ($level > 1) { | |||||
$matrix->setApplySmoothing(true); | |||||
} | |||||
$u_pos = 0; | $u_pos = 0; | ||||
$v_pos = 0; | $v_pos = 0; | ||||
$edits = $matrix->getEditString(); | $edits = $matrix->getEditString(); | ||||
$edits_length = strlen($edits); | $edits_length = strlen($edits); | ||||
for ($ii = 0; $ii < $edits_length; $ii++) { | for ($ii = 0; $ii < $edits_length; $ii++) { | ||||
$c = $edits[$ii]; | $c = $edits[$ii]; | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |