X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdiff%2FTableDiffFormatter.php;h=bcae7467f777e008c62131713f6b96f720e6b514;hb=d199da516c7ae96e0d52b9287db333d40d440b7a;hp=f1826edc5ec8d36fce03704a22c94d012a5aa3df;hpb=a85d1b9d0cd7f02111d3a647d5b91e3b1f334563;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/diff/TableDiffFormatter.php b/includes/diff/TableDiffFormatter.php index f1826edc5e..bcae7467f7 100644 --- a/includes/diff/TableDiffFormatter.php +++ b/includes/diff/TableDiffFormatter.php @@ -204,16 +204,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" ); } }