Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
+----------------------------------------------------------------------------------------------+
| Sample.received.txt <> Sample.verified.txt diff |
+----------------------------------------------+-----------------------------------------------+
| Sample.received.txt | Sample.verified.txt |
+----------------------------------------------+-----------------------------------------------+
| 1 the quick | 1 the quick |
| ~ 2 brown fox | ~ 2 brown fox |
| ~ 3 dog | ~ 3 dog |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+----------------------------------------------+-----------------------------------------------+
| [Accept] [Close] lines 1-3 of 3 |
+----------------------------------------------------------------------------------------------+
12 changes: 12 additions & 0 deletions src/DiffEngineViewer.Tests/FileScreenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ public Task LeftEmpty() =>
public Task RightEmpty() =>
Verify(Fixtures.Render(Fixtures.File(right: "")));

/// <summary>
/// A snapshot that differs only in whitespace still has to render as a difference. DiffPlex
/// ignores whitespace by default, which turned this into three Unchanged rows.
/// </summary>
[Test]
public Task WhitespaceOnly() =>
Verify(
Fixtures.Render(
Fixtures.File(
"the quick\n brown fox\ndog ",
"the quick\nbrown fox\ndog")));

[Test]
public Task LongLines()
{
Expand Down
10 changes: 9 additions & 1 deletion src/DiffEngineViewer/DiffRows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ static class DiffRows
public static (IReadOnlyList<Row> Left, IReadOnlyList<Row> Right) Build(string leftText, string rightText)
{
// DiffPlex is old/new oriented. Left is the received (new) side, right the expected (old).
var model = SideBySideDiffBuilder.Diff(rightText, leftText);
// ignoreWhiteSpace defaults to true, which is wrong for a snapshot: a test that fails only
// on indentation or a trailing space came back Unchanged on every row, so the panes drew no
// markers, NextChange found nothing, and the reviewer was shown a failure with no visible
// difference. Whitespace is exactly what the F# layout convention is about.
var model = SideBySideDiffBuilder.Diff(
rightText,
leftText,
ignoreWhiteSpace: false,
ignoreCase: false);
return (Convert(model.NewText.Lines), Convert(model.OldText.Lines));
}

Expand Down
Loading