Browse Source

added DocumentSequence - works on a per line basis, not per character

pull/15/head
Siegfried Pammer 15 years ago
parent
commit
966fe142f2
  1. 1
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
  2. 39
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/MyersDiff/DocumentSequence.cs
  3. 4
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/MyersDiff/StringSequence.cs

1
src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj

@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
<Compile Include="Src\ContextActionsRenderer.cs" />
<Compile Include="Src\DefaultChangeWatcher.cs" />
<Compile Include="Src\ExpressionHighlightRenderer.cs" />
<Compile Include="Src\MyersDiff\DocumentSequence.cs" />
<Compile Include="Src\MyersDiff\Edit.cs" />
<Compile Include="Src\MyersDiff\ISequence.cs" />
<Compile Include="Src\MyersDiff\MyersDiff.cs" />

39
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/MyersDiff/DocumentSequence.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn.MyersDiff
{
public class DocumentSequence : ISequence
{
IDocument document;
List<int> hashCodes;
public DocumentSequence(IDocument document)
{
this.document = document;
this.hashCodes = new List<int>();
}
public int Size()
{
return document.TotalNumberOfLines;
}
public bool Equals(int i, ISequence other, int j)
{
DocumentSequence seq = other as DocumentSequence;
if (seq == null)
return false;
IDocumentLine thisLine = document.GetLine(i + 1);
IDocumentLine otherLine = seq.document.GetLine(j + 1);
return thisLine.Text == otherLine.Text;
}
}
}

4
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/MyersDiff/StringSequence.cs

@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn.MyersDiff
{
@ -29,6 +31,4 @@ namespace ICSharpCode.AvalonEdit.AddIn.MyersDiff @@ -29,6 +31,4 @@ namespace ICSharpCode.AvalonEdit.AddIn.MyersDiff
return content[i] == seq.content[j];
}
}
}

Loading…
Cancel
Save