private void UpdateCompareContent() { if (Left != null && Right != null) { var diff = DiffModule.DiffMain(Left.RawContents, Right.RawContents); DiffModule.DiffCleanupSemantic(diff); if (Comparison != null) { Comparison.RebuildRequested -= Comparison_RebuildRequested; } Comparison = new Comparison(diff); Comparison.RebuildRequested += Comparison_RebuildRequested; LeftDocument.Text = Comparison.Root?.GetAsString(Side.Left); RightDocument.Text = Comparison.Root?.GetAsString(Side.Right); ResultDocument.Changed -= _resultDocument_Changed; ResultDocument.Text = Comparison.Root?.GetAsString(Side.Result); ResultDocument.Changed += _resultDocument_Changed; } }
private static string GetBody(Base o) { var diffMatchPatch = new DiffMatchPatch.DiffMatchPatch(); var differents = diffMatchPatch.DiffMain(o.Changes.Body.From, o.Issue.Body); diffMatchPatch.DiffCleanupSemantic(differents); //diffMatchPatch.DiffCleanupEfficiency(differents); return(diffMatchPatch.DiffEmbedBody(differents)); //return "```diff\n" + diffMatchPatch.DiffEmbedBody(differents) + "```"; /* var strBuilder = new StringBuilder(); * if (differents.Any(d => d.operation == DiffMatchPatch.Operation.INSERT)) * { * strBuilder.AppendLine("Added:"); * foreach (var diff in differents.Where(d => d.operation == DiffMatchPatch.Operation.INSERT).Select(d => d.text)) * { * strBuilder.AppendLine(diff); * } * } * * if (differents.Any(d => d.operation == DiffMatchPatch.Operation.DELETE)) * { * if (strBuilder.Length > 0) * strBuilder.AppendLine(); * strBuilder.AppendLine("Removed:"); * foreach (var diff in differents.Where(d => d.operation == DiffMatchPatch.Operation.DELETE).Select(d => d.text)) * { * strBuilder.AppendLine(diff); * } * } * * return strBuilder.ToString();*/ }