Skip to content
This repository was archived by the owner on Dec 7, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions finediff.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class FineDiff {
*/
public function __construct($from_text = '', $to_text = '', $granularityStack = null) {
// setup stack for generic text documents by default
$this->insertions_count = 0;
$this->deletions_count = 0;
$this->granularityStack = $granularityStack ? $granularityStack : FineDiff::$characterGranularity;
$this->edits = array();
$this->from_text = $from_text;
Expand Down Expand Up @@ -407,8 +409,22 @@ private function _processGranularity($from_segment, $to_segment) {
/* $fragment_edit instanceof FineDiffCopyOp */
/* $fragment_edit instanceof FineDiffDeleteOp */
/* $fragment_edit instanceof FineDiffInsertOp */
/* $fragment_edit instanceof fineDiffReplaceOp */
$this->edits[] = $this->last_edit = $fragment_edit;
$this->from_offset += $fragment_edit->getFromLen();
// increase insertion count
if ( $fragment_edit instanceof fineDiffInsertOp ) {
$this->insertions_count++;
}
// increase deletion count
else if ( $fragment_edit instanceof fineDiffDeleteOp ) {
$this->deletions_count++;
}
// increase insertion and deletion count
else if ( $fragment_edit instanceof fineDiffReplaceOp ) {
$this->insertions_count++;
$this->deletions_count++;
}
}
}
$this->stackpointer--;
Expand Down