X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdiff%2FTableDiffFormatter.php;h=14307b58440008a5a5335db81984f9057ad34d09;hb=d6276525455e6a00fffc90229ef81a1fc8feaa25;hp=f1826edc5ec8d36fce03704a22c94d012a5aa3df;hpb=e3bd13db0c285f312e31bb1b7271af4628cca80c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/diff/TableDiffFormatter.php b/includes/diff/TableDiffFormatter.php index f1826edc5e..14307b5844 100644 --- a/includes/diff/TableDiffFormatter.php +++ b/includes/diff/TableDiffFormatter.php @@ -196,7 +196,6 @@ class TableDiffFormatter extends DiffFormatter { * @param string[] $closing */ protected function changed( $orig, $closing ) { - $diff = new WordLevelDiff( $orig, $closing ); $del = $diff->orig(); $add = $diff->closing(); @@ -204,16 +203,13 @@ class TableDiffFormatter extends DiffFormatter { # Notice that WordLevelDiff returns HTML-escaped output. # Hence, we will be calling addedLine/deletedLine without HTML-escaping. - $line = array_shift( $del ); - while ( $line ) { - $aline = array_shift( $add ); - $this->writeOutput( '' . $this->deletedLine( $line ) . - $this->addedLine( $aline ) . "\n" ); - $line = array_shift( $del ); - } - foreach ( $add as $line ) { # If any leftovers - $this->writeOutput( '' . $this->emptyLine() . - $this->addedLine( $line ) . "\n" ); + $ndel = count( $del ); + $nadd = count( $add ); + $n = max( $ndel, $nadd ); + for ( $i = 0; $i < $n; $i++ ) { + $delLine = $i < $ndel ? $this->deletedLine( $del[$i] ) : $this->emptyLine(); + $addLine = $i < $nadd ? $this->addedLine( $add[$i] ) : $this->emptyLine(); + $this->writeOutput( "{$delLine}{$addLine}\n" ); } }