From 223467480f87bbd0ca4c76a99e6d88a9e7cf915a Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 28 Mar 2024 09:34:08 +0800 Subject: [PATCH] fix: wrong work tree file path --- src/SourceGit/ViewModels/DiffContext.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/SourceGit/ViewModels/DiffContext.cs b/src/SourceGit/ViewModels/DiffContext.cs index 6fb5d99b..02c8aa9d 100644 --- a/src/SourceGit/ViewModels/DiffContext.cs +++ b/src/SourceGit/ViewModels/DiffContext.cs @@ -3,6 +3,7 @@ using System.IO; using System.Threading.Tasks; using Avalonia; +using Avalonia.Media.Imaging; using Avalonia.Threading; using CommunityToolkit.Mvvm.ComponentModel; @@ -105,8 +106,9 @@ namespace SourceGit.ViewModels } else { + var fullPath = Path.Combine(repo, _option.Path); imgDiff.Old = Commands.GetImageFileAsBitmap.Run(repo, "HEAD", oldPath); - imgDiff.New = File.Exists(_option.Path) ? new Avalonia.Media.Imaging.Bitmap(_option.Path) : null; + imgDiff.New = File.Exists(fullPath) ? new Bitmap(fullPath) : null; } rs = imgDiff; } @@ -120,8 +122,9 @@ namespace SourceGit.ViewModels } else { + var fullPath = Path.Combine(repo, _option.Path); binaryDiff.OldSize = new Commands.QueryFileSize(repo, oldPath, "HEAD").Result(); - binaryDiff.NewSize = new FileInfo(Path.Combine(repo, _option.Path)).Length; + binaryDiff.NewSize = File.Exists(fullPath) ? new FileInfo(fullPath).Length : 0; } rs = binaryDiff; }