Skip to content

Commit

Permalink
use some pattern matching in SideBySideDiffBuilder.BuildDiffPieces
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored and mmanela committed Jul 12, 2024
1 parent 0a0333f commit aa41237
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions DiffPlex/DiffBuilder/SideBySideDiffBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ private static ChangeType BuildDiffPieces(DiffResult diffResult, List<DiffPiece>
int aPos = 0;
int bPos = 0;

ChangeType changeSummary = ChangeType.Unchanged;

foreach (var diffBlock in diffResult.DiffBlocks)
{
while (bPos < diffBlock.InsertStartB && aPos < diffBlock.DeleteStartA)
Expand Down Expand Up @@ -189,16 +187,17 @@ private static ChangeType BuildDiffPieces(DiffResult diffResult, List<DiffPiece>
}

// Consider the whole diff as "modified" if we found any change, otherwise we consider it unchanged
if(oldPieces.Any(x=> x.Type == ChangeType.Modified || x.Type == ChangeType.Inserted || x.Type == ChangeType.Deleted))
if(oldPieces.Any(x => x.Type is ChangeType.Modified or ChangeType.Inserted or ChangeType.Deleted))
{
changeSummary = ChangeType.Modified;
return ChangeType.Modified;
}
else if (newPieces.Any(x => x.Type == ChangeType.Modified || x.Type == ChangeType.Inserted || x.Type == ChangeType.Deleted))

if (newPieces.Any(x => x.Type is ChangeType.Modified or ChangeType.Inserted or ChangeType.Deleted))
{
changeSummary = ChangeType.Modified;
return ChangeType.Modified;
}

return changeSummary;
return ChangeType.Unchanged;
}
}
}

0 comments on commit aa41237

Please sign in to comment.