Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcean authored Dec 12, 2024
2 parents 382953d + 6d7c70a commit f6796c9
Show file tree
Hide file tree
Showing 32 changed files with 94 additions and 102 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: mmanela
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,7 @@ GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

.DS_Store
.DS_Store

#Rider
.idea
1 change: 0 additions & 1 deletion DiffPlex.ConsoleRunner/DiffPlex.ConsoleRunner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>10.0</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions DiffPlex.Windows/DiffPlex.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageTags>diff</PackageTags>
<PackageIcon>diffplex_icon.png</PackageIcon>
<Description>DiffPlex.Windows is a Windows App SDK control library that allows you to programatically render visual text diffs in your application.</Description>
<LangVersion>12.0</LangVersion>
<LangVersion>13.0</LangVersion>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<Authors>Kingcean Tuan; Matthew Manela</Authors>
Expand All @@ -31,7 +31,6 @@
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="README.md" />
<None Include="..\License.txt" Pack="true" PackagePath="License.txt" />
<None Include="..\images\diffplex_icon.png" Pack="true" PackagePath="diffplex_icon.png" />
</ItemGroup>

Expand Down
18 changes: 2 additions & 16 deletions DiffPlex.WindowsForms.Demo/DiffPlex.WindowsForms.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,17 @@
<TargetFrameworks>net6.0-windows;net46</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Kingcean Tuan</Authors>
<Company />
<RootNamespace>DiffPlex.WindowsForms</RootNamespace>
<AssemblyName>DiffPlex.WindowsForms.Demo</AssemblyName>
<PackageLicenseUrl>https://github.com/mmanela/diffplex/blob/master/License.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/mmanela/diffplex/</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/mmanela/diffplex.git</RepositoryUrl>
<PackageIcon>diffplex_icon.png</PackageIcon>
<ApplicationIcon>..\DiffPlex.ico</ApplicationIcon>
<LangVersion>10.0</LangVersion>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\DiffPlex.Wpf.Demo\TestData.cs" Link="TestData.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DiffPlex.Wpf\DiffPlex.Wpf.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\DiffPlex.Wpf.Demo\TestData.cs" Link="TestData.cs" />
<Content Include="..\DiffPlex.ico" Link="DiffPlex.ico" />
<None Include="..\License.txt" Pack="true" PackagePath="License.txt" />
<None Include="..\images\diffplex_icon.png" Pack="true" PackagePath="diffplex_icon.png" />
</ItemGroup>

</Project>
16 changes: 1 addition & 15 deletions DiffPlex.Wpf.Demo/DiffPlex.Wpf.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
<TargetFrameworks>net9.0-windows;net48</TargetFrameworks>
<UseWPF>true</UseWPF>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Authors>Kingcean Tuan</Authors>
<Company />
<RootNamespace>DiffPlex.Wpf</RootNamespace>
<AssemblyName>DiffPlex.Wpf.Demo</AssemblyName>
<PackageLicenseUrl>https://github.com/mmanela/diffplex/blob/master/License.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/mmanela/diffplex/</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/mmanela/diffplex.git</RepositoryUrl>
<PackageIcon>diffplex_icon.png</PackageIcon>
<StartupObject>DiffPlex.Wpf.Demo.App</StartupObject>
<ApplicationIcon>..\DiffPlex.ico</ApplicationIcon>
<LangVersion>10.0</LangVersion>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<ItemGroup>
Expand All @@ -25,11 +16,6 @@

<ItemGroup>
<Content Include="..\DiffPlex.ico" Link="DiffPlex.ico" />
<None Include="..\License.txt" Pack="true" PackagePath="License.txt" />
<None Include="..\images\diffplex_icon.png" Pack="true" PackagePath="diffplex_icon.png" />
</ItemGroup>

<ItemGroup>
<Resource Include="..\DiffPlex.Wpf\Icon.png" Link="Icon.png" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions DiffPlex.Wpf/Controls/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private static IEnumerable<Tuple<DiffPiece, bool>> GetLineViewportStates(Interna
{
if (item is not FrameworkElement ele || ele.Tag is not DiffPiece line) continue;
var pos = ele.TranslatePoint(point, panel.ValueScrollViewer);
var isIn = pos.Y >= 0 && pos.Y <= scrollView.ActualHeight - ele.ActualHeight;
var isIn = ele.ActualHeight > 0 && pos.Y >= 0 && pos.Y <= scrollView.ActualHeight - ele.ActualHeight;
yield return new Tuple<DiffPiece, bool>(line, isIn);
}

Expand All @@ -426,7 +426,7 @@ private static IEnumerable<Tuple<DiffPiece, bool>> GetLineViewportStates(Interna
if (item is not FrameworkElement ele || ele.Tag is not DiffPiece line) continue;
var pos = ele.TranslatePoint(point, panel.ValueScrollViewer);
var halfHeight = ele.ActualHeight / 2;
var isIn = pos.Y >= -halfHeight && pos.Y <= scrollView.ActualHeight - halfHeight;
var isIn = halfHeight > 0 && pos.Y >= -halfHeight && pos.Y <= scrollView.ActualHeight - halfHeight;
yield return new Tuple<DiffPiece, bool>(line, isIn);
}

Expand All @@ -436,7 +436,7 @@ private static IEnumerable<Tuple<DiffPiece, bool>> GetLineViewportStates(Interna
{
if (item is not FrameworkElement ele || ele.Tag is not DiffPiece line) continue;
var pos = ele.TranslatePoint(point, panel.ValueScrollViewer);
var isIn = pos.Y > -ele.ActualHeight && pos.Y < scrollView.ActualHeight;
var isIn = ele.ActualHeight > 0 && pos.Y > -ele.ActualHeight && pos.Y < scrollView.ActualHeight;
yield return new Tuple<DiffPiece, bool>(line, isIn);
}

Expand Down
2 changes: 1 addition & 1 deletion DiffPlex.Wpf/DiffPlex.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<AssemblyVersion>1.4.0.0</AssemblyVersion>
<FileVersion>1.4.0.0</FileVersion>
<ApplicationIcon>..\DiffPlex.ico</ApplicationIcon>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>
<ItemGroup>
<Content Include="..\License.txt" Link="License.txt" />
<Content Include="..\DiffPlex.ico" Link="DiffPlex.ico" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions DiffPlex.Wpf/Forms/DiffViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ public Color InsertedForeColor
/// </summary>
public Color InsertedBackColor
{
get => GetColor(Core.InsertedForeground);
set => Core.InsertedForeground = ToBrush(value);
get => GetColor(Core.InsertedBackground);
set => Core.InsertedBackground = ToBrush(value);
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions DiffPlex.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
NuGet.props = NuGet.props
README.md = README.md
images\website.png = images\website.png
global.json = global.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiffPlex.Wpf", "DiffPlex.Wpf\DiffPlex.Wpf.csproj", "{CB18D73D-7E84-4B28-B44D-93CB34794A6A}"
Expand Down
6 changes: 4 additions & 2 deletions DiffPlex/Chunkers/CharacterChunker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace DiffPlex.Chunkers
using System.Collections.Generic;

namespace DiffPlex.Chunkers
{
public class CharacterChunker:IChunker
{
Expand All @@ -7,7 +9,7 @@ public class CharacterChunker:IChunker
/// </summary>
public static CharacterChunker Instance { get; } = new CharacterChunker();

public string[] Chunk(string text)
public IReadOnlyList<string> Chunk(string text)
{
var s = new string[text.Length];
for (int i = 0; i < text.Length; i++) s[i] = text[i].ToString();
Expand Down
7 changes: 4 additions & 3 deletions DiffPlex/Chunkers/CustomFunctionChunker.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using System;
using System.Collections.Generic;

namespace DiffPlex.Chunkers
{
public class CustomFunctionChunker: IChunker
{
private readonly Func<string, string[]> customChunkerFunc;
private readonly Func<string, IReadOnlyList<string>> customChunkerFunc;

public CustomFunctionChunker(Func<string, string[]> customChunkerFunc)
public CustomFunctionChunker(Func<string, IReadOnlyList<string>> customChunkerFunc)
{
if (customChunkerFunc == null) throw new ArgumentNullException(nameof(customChunkerFunc));
this.customChunkerFunc = customChunkerFunc;
}

public string[] Chunk(string text)
public IReadOnlyList<string> Chunk(string text)
{
return customChunkerFunc(text);
}
Expand Down
4 changes: 2 additions & 2 deletions DiffPlex/Chunkers/DelimiterChunker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public DelimiterChunker(char[] delimiters)
this.delimiters = delimiters;
}

public string[] Chunk(string str)
public IReadOnlyList<string> Chunk(string str)
{
var list = new List<string>();
int begin = 0;
Expand Down Expand Up @@ -76,7 +76,7 @@ public string[] Chunk(string str)
}
}

return list.ToArray();
return list;
}
}
}
3 changes: 2 additions & 1 deletion DiffPlex/Chunkers/LineChunker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace DiffPlex.Chunkers
{
Expand All @@ -11,7 +12,7 @@ public class LineChunker:IChunker
/// </summary>
public static LineChunker Instance { get; } = new LineChunker();

public string[] Chunk(string text)
public IReadOnlyList<string> Chunk(string text)
{
return text.Split(lineSeparators, StringSplitOptions.None);
}
Expand Down
4 changes: 2 additions & 2 deletions DiffPlex/Chunkers/LineEndingsPreservingChunker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LineEndingsPreservingChunker:IChunker
/// </summary>
public static LineEndingsPreservingChunker Instance { get; } = new LineEndingsPreservingChunker();

public string[] Chunk(string text)
public IReadOnlyList<string> Chunk(string text)
{
if (string.IsNullOrEmpty(text))
return emptyArray;
Expand Down Expand Up @@ -45,7 +45,7 @@ public string[] Chunk(string text)
output.Add(str);
}

return output.ToArray();
return output;
}
}
}
4 changes: 2 additions & 2 deletions DiffPlex/Chunkers/WordChunker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
{
public class WordChunker:DelimiterChunker
{
private static char[] WordSeparaters { get; } = { ' ', '\t', '.', '(', ')', '{', '}', ',', '!', '?', ';' };
private static char[] WordSeparators { get; } = { ' ', '\t', '.', '(', ')', '{', '}', ',', '!', '?', ';' };

/// <summary>
/// Gets the default singleton instance of the chunker.
/// </summary>
public static WordChunker Instance { get; } = new WordChunker();

public WordChunker() : base(WordSeparaters)
public WordChunker() : base(WordSeparators)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion DiffPlex/DiffBuilder/InlineDiffBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static void BuildDiffPieces(DiffResult diffResult, List<DiffPiece> piece
}
}

for (; bPos < diffResult.PiecesNew.Length; bPos++)
for (; bPos < diffResult.PiecesNew.Count; bPos++)
pieces.Add(new DiffPiece(diffResult.PiecesNew[bPos], ChangeType.Unchanged, bPos + 1));
}
}
Expand Down
15 changes: 7 additions & 8 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 @@ -180,7 +178,7 @@ private static ChangeType BuildDiffPieces(DiffResult diffResult, List<DiffPiece>
}
}

while (bPos < diffResult.PiecesNew.Length && aPos < diffResult.PiecesOld.Length)
while (bPos < diffResult.PiecesNew.Count && aPos < diffResult.PiecesOld.Count)
{
oldPieces.Add(new DiffPiece(diffResult.PiecesOld[aPos], ChangeType.Unchanged, aPos + 1));
newPieces.Add(new DiffPiece(diffResult.PiecesNew[bPos], ChangeType.Unchanged, bPos + 1));
Expand All @@ -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;
}
}
}
10 changes: 4 additions & 6 deletions DiffPlex/DiffPlex.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\NuGet.props" />
<PropertyGroup>
<TargetFrameworks>net35;net40;netstandard1.0;netstandard2.0;net6.0</TargetFrameworks>
<Version>1.7.1</Version>
<TargetFrameworks>net45;netstandard1.0;netstandard2.0;net6.0</TargetFrameworks>
<Version>1.7.2</Version>
<PackageTags>diff</PackageTags>
<Description>DiffPlex is a diffing library that allows you to programatically create text diffs. DiffPlex is a fast and tested library.</Description>
<PackageReleaseNotes>Fixed diffing of sub-components (like words). Ensures ignoreWhitespace and ignoreCase are honoroed in that case and that the parent reflects modification state of the child.</PackageReleaseNotes>
<Description>DiffPlex is a diffing library that allows you to programmatically create text diffs. DiffPlex is a fast and tested library.</Description>
<PackageReleaseNotes>Fixed diffing of sub-components (like words). Ensures ignoreWhitespace and ignoreCase are honored in that case and that the parent reflects modification state of the child.</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net40'" Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
<PackageReference Condition="'$(TargetFramework)' == 'net35'" Include="jnm2.ReferenceAssemblies.net35" Version="1.0.1" PrivateAssets="all" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
Loading

0 comments on commit f6796c9

Please sign in to comment.