mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
refactor: improve diff handling for EOL changes and enhance text diff… (#1177)
* refactor: improve diff handling for EOL changes and enhance text diff display - Updated `Diff.cs` to streamline whitespace handling in diff arguments. - Enhanced `DiffContext.cs` to check for EOL changes when old and new hashes differ, creating a text diff if necessary. - Added support for showing end-of-line symbols in `TextDiffView.axaml.cs` options. * localization: update translations to include EOF handling in ignore whitespace messages - Modified the ignore whitespace text in multiple language files to specify that EOF changes are also ignored. - Ensured consistency across all localization files for the patch application feature. * revert: Typo in DiffResult comment * revert: update diff arguments to ignore CR at EOL in whitespace handling (like before changes) * revert: update translations to remove EOF references in Text.Apply.IgnoreWS and fixed typo in Text.Diff.IgnoreWhitespace (EOF => EOL) --------- Co-authored-by: mpagani <massimo.pagani@unitec-group.com>
This commit is contained in:
parent
e7f0217a7b
commit
81820e7034
14 changed files with 57 additions and 13 deletions
|
@ -207,7 +207,50 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
rs = new Models.NoOrEOLChange();
|
||||
// Check if old and new hashes differ but no text changes found
|
||||
if (!string.IsNullOrEmpty(latest.OldHash) &&
|
||||
!string.IsNullOrEmpty(latest.NewHash) &&
|
||||
latest.OldHash != latest.NewHash)
|
||||
{
|
||||
// If hashes differ but no text diff found, it's likely an EOL change
|
||||
// Create a text diff to show the file content
|
||||
var textDiff = new Models.TextDiff()
|
||||
{
|
||||
Repo = _repo,
|
||||
Option = _option,
|
||||
File = _option.Path
|
||||
};
|
||||
// Query the file content to show
|
||||
var fileContent = Commands.QueryFileContent.Run(_repo, "HEAD", _option.Path);
|
||||
using var reader = new StreamReader(fileContent);
|
||||
var line = string.Empty;
|
||||
int lineNumber = 1;
|
||||
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
textDiff.Lines.Add(new Models.TextDiffLine(
|
||||
Models.TextDiffLineType.Normal,
|
||||
line,
|
||||
lineNumber,
|
||||
lineNumber));
|
||||
|
||||
lineNumber++;
|
||||
}
|
||||
|
||||
if (textDiff.Lines.Count > 0)
|
||||
{
|
||||
textDiff.MaxLineNumber = lineNumber - 1;
|
||||
rs = textDiff;
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = new Models.NoOrEOLChange();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rs = new Models.NoOrEOLChange();
|
||||
}
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue