mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-21 02:15:00 +00:00
Refactored handling of diff object into separate function
This commit is contained in:
parent
05e2936abf
commit
0cc565d193
1 changed files with 102 additions and 88 deletions
|
@ -7,6 +7,7 @@ using Avalonia.Media.Imaging;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using SourceGit.Models;
|
||||||
|
|
||||||
namespace SourceGit.ViewModels
|
namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -144,6 +145,23 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
_info = info;
|
_info = info;
|
||||||
|
|
||||||
|
var rs = GetDiffObject(latest);
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
{
|
||||||
|
if (_content is Models.TextDiff old && rs is Models.TextDiff cur && old.File == cur.File)
|
||||||
|
cur.ScrollOffset = old.ScrollOffset;
|
||||||
|
|
||||||
|
FileModeChange = latest.FileModeChange;
|
||||||
|
Content = rs;
|
||||||
|
IsLFSDiff = latest.IsLFS;
|
||||||
|
IsTextDiff = rs is Models.TextDiff;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private object GetDiffObject(DiffResult latest)
|
||||||
|
{
|
||||||
var rs = null as object;
|
var rs = null as object;
|
||||||
if (latest.TextDiff != null)
|
if (latest.TextDiff != null)
|
||||||
{
|
{
|
||||||
|
@ -232,18 +250,14 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
rs = new Models.NoOrEOLChange();
|
rs = new Models.NoOrEOLChange();
|
||||||
}
|
}
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
private string GetLFSObjectPath(string oid)
|
||||||
{
|
{
|
||||||
if (_content is Models.TextDiff old && rs is Models.TextDiff cur && old.File == cur.File)
|
var lfsDir = Path.Combine(".git", "lfs", "objects", oid.Substring(0, 2), oid.Substring(2, 2), oid);
|
||||||
cur.ScrollOffset = old.ScrollOffset;
|
|
||||||
|
|
||||||
FileModeChange = latest.FileModeChange;
|
return lfsDir;
|
||||||
Content = rs;
|
|
||||||
IsLFSDiff = latest.IsLFS;
|
|
||||||
IsTextDiff = rs is Models.TextDiff;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private (Bitmap, long) BitmapFromRevisionFile(string repo, string revision, string file)
|
private (Bitmap, long) BitmapFromRevisionFile(string repo, string revision, string file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue