Issue #3389715: DiffOpOutputBuilder::hunkOp does not handle Differ::DIFF_LINE_END_WARNING
Merge request reports
Activity
43 43 $hunkTarget = []; 44 44 45 45 for ($i = 0; $i < count($diff); $i++) { 46 // Ignore line end warnings. 47 if ($diff[$i][1] === Differ::DIFF_LINE_END_WARNING) { 48 // @todo maybe we can log them or report them somehow. 49 continue; 50 } - Comment on lines +46 to +50
It's worth noting how
\SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder
handles this:for ($i = $diffStartIndex; $i < $diffEndIndex; ++$i) { if ($diff[$i][1] === Differ::ADDED) { fwrite($output, '+' . $diff[$i][0]); } elseif ($diff[$i][1] === Differ::REMOVED) { fwrite($output, '-' . $diff[$i][0]); } elseif ($diff[$i][1] === Differ::OLD) { fwrite($output, ' ' . $diff[$i][0]); } elseif ($diff[$i][1] === Differ::NO_LINE_END_EOF_WARNING) { fwrite($output, "\n"); // $diff[$i][0] } else { /* Not changed (old) Differ::OLD or Warning Differ::DIFF_LINE_END_WARNING */ fwrite($output, ' ' . $diff[$i][0]); } }
Essentially treats the warning as "not changed".
We may also want to handle "Differ::NO_LINE_END_EOF_WARNING".
It seems the only usage of
\SebastianBergmann\Diff\Differ::NO_LINE_END_EOF_WARNING
is in\SebastianBergmann\Diff\Output\StrictUnifiedDiffOutputBuilder
and\SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder
, neither of which are used in core. This means we will never see this warning.This differs from
\SebastianBergmann\Diff\Differ::DIFF_LINE_END_WARNING
as that is called from\SebastianBergmann\Diff\Differ::diffToArray
which is called in\Drupal\Component\Diff\Diff::__construct
.I think we can leave it as is for now where
\Drupal\Component\Diff\DiffOpOutputBuilder::hunkOp
will throw an InvalidArgumentException.
added 44 commits
-
0c97543c...9698403e - 43 commits from branch
project:11.x
- 4f93c41e - Merge branch '11.x' into 3389715-diff-line-ending
-
0c97543c...9698403e - 43 commits from branch