Skip to content

Commit 70ffe9a

Browse files
committed
fix: rename change diff
1 parent a86a9cf commit 70ffe9a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/ViewModels/FileHistories.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,24 @@ private void SetViewContentAsDiff()
153153
{
154154
var revisionFilePath = new Commands.QueryFilePathInRevision(_repo.FullPath, _revision.SHA, _file).Result();
155155

156-
var option = new Models.DiffOption(_revision, revisionFilePath);
157-
ViewContent = new DiffContext(_repo.FullPath, option, _viewContent as DiffContext);
156+
if (_revision.Parents.Count > 0)
157+
{
158+
var parentSHA = _revision.Parents[0];
159+
var changes = new Commands.CompareRevisions(_repo.FullPath, parentSHA, _revision.SHA).Result();
160+
foreach (var change in changes)
161+
{
162+
if ((change.WorkTree == Models.ChangeState.Renamed || change.Index == Models.ChangeState.Renamed)
163+
&& change.Path == revisionFilePath)
164+
{
165+
var option = new Models.DiffOption(parentSHA, _revision.SHA, change);
166+
ViewContent = new DiffContext(_repo.FullPath, option, _viewContent as DiffContext);
167+
return;
168+
}
169+
}
170+
}
171+
172+
var defaultOption = new Models.DiffOption(_revision, revisionFilePath);
173+
ViewContent = new DiffContext(_repo.FullPath, defaultOption, _viewContent as DiffContext);
158174
}
159175

160176
[GeneratedRegex(@"^version https://git-lfs.github.com/spec/v\d+\r?\noid sha256:([0-9a-f]+)\r?\nsize (\d+)[\r\n]*$")]

0 commit comments

Comments
 (0)