mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
optimize<Diff>: limit number of character diff; ignore empty changes
This commit is contained in:
parent
18f35449e5
commit
789e3cf6a2
1 changed files with 5 additions and 2 deletions
|
@ -77,10 +77,13 @@ namespace SourceGit.Commands {
|
|||
for (int i = added.Count - 1; i >= 0; i--) {
|
||||
var left = deleted[i];
|
||||
var right = added[i];
|
||||
|
||||
var result = DiffPlex.Differ.Instance.CreateCharacterDiffs(left.Content, right.Content, false, false);
|
||||
if (result.DiffBlocks.Count > 4) break;
|
||||
|
||||
foreach (var block in result.DiffBlocks) {
|
||||
left.Highlights.Add(new Models.TextChanges.HighlightRange(block.DeleteStartA, block.DeleteCountA));
|
||||
right.Highlights.Add(new Models.TextChanges.HighlightRange(block.InsertStartB, block.InsertCountB));
|
||||
if (block.DeleteCountA > 0) left.Highlights.Add(new Models.TextChanges.HighlightRange(block.DeleteStartA, block.DeleteCountA));
|
||||
if (block.InsertCountB > 0) right.Highlights.Add(new Models.TextChanges.HighlightRange(block.InsertStartB, block.InsertCountB));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue