From 0fadab2ca20d19ba734e3994088e36ae33a7ae62 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 21 Mar 2024 21:24:53 +0800 Subject: [PATCH] fix: select file with only eol changes after other change types will not update diff result --- src/SourceGit/Models/DiffResult.cs | 7 ++++--- src/SourceGit/ViewModels/DiffContext.cs | 1 + src/SourceGit/Views/DiffView.axaml | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/SourceGit/Models/DiffResult.cs b/src/SourceGit/Models/DiffResult.cs index 1c73aa5b..6d6017e7 100644 --- a/src/SourceGit/Models/DiffResult.cs +++ b/src/SourceGit/Models/DiffResult.cs @@ -380,8 +380,6 @@ namespace SourceGit.Models private bool ProcessIndicatorForPatch(StringBuilder builder, TextDiffLine indicator, int idx, int start, int end, int ignoreRemoves, int ignoreAdds, bool revert, bool tailed) { - - var match = indicatorRegex().Match(indicator.Content); var oldStart = int.Parse(match.Groups[1].Value); var newStart = int.Parse(match.Groups[2].Value) + ignoreRemoves - ignoreAdds; @@ -449,7 +447,6 @@ namespace SourceGit.Models private bool ProcessIndicatorForPatchSingleSide(StringBuilder builder, TextDiffLine indicator, int idx, int start, int end, int ignoreRemoves, int ignoreAdds, bool revert, bool isOldSide, bool tailed) { - var match = indicatorRegex().Match(indicator.Content); var oldStart = int.Parse(match.Groups[1].Value); var newStart = int.Parse(match.Groups[2].Value) + ignoreRemoves - ignoreAdds; @@ -550,6 +547,10 @@ namespace SourceGit.Models public long NewSize { get; set; } = 0; } + public class NoOrEOLChange + { + } + public class DiffResult { public bool IsBinary { get; set; } = false; diff --git a/src/SourceGit/ViewModels/DiffContext.cs b/src/SourceGit/ViewModels/DiffContext.cs index c0654c82..ef3f63e3 100644 --- a/src/SourceGit/ViewModels/DiffContext.cs +++ b/src/SourceGit/ViewModels/DiffContext.cs @@ -131,6 +131,7 @@ namespace SourceGit.ViewModels } else { + Content = new Models.NoOrEOLChange(); IsTextDiff = false; IsNoChange = true; } diff --git a/src/SourceGit/Views/DiffView.axaml b/src/SourceGit/Views/DiffView.axaml index 6924d6c6..e3933839 100644 --- a/src/SourceGit/Views/DiffView.axaml +++ b/src/SourceGit/Views/DiffView.axaml @@ -52,18 +52,6 @@ - - - - - - - - @@ -125,6 +113,18 @@ + + + + + + + +