Skip to content

Commit c25c3a7

Browse files
committed
Fix "fast path" detection of unaltered files when opening temporary copies
1 parent 373d037 commit c25c3a7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

GitDiffMargin/Git/GitCommands.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ public IEnumerable<HunkRangeInfo> GetGitDiffFor(ITextDocument textDocument, stri
5959
yield break;
6060
}
6161

62-
if (retrieveStatus == FileStatus.Unaltered && !textDocument.IsDirty)
62+
if (retrieveStatus == FileStatus.Unaltered
63+
&& !textDocument.IsDirty
64+
&& Path.GetFullPath(filename) == originalPath)
6365
{
64-
// truly unaltered
66+
// Truly unaltered. The `IsDirty` check isn't valid for cases where the textDocument is a view of a
67+
// temporary copy of the file, since the temporary copy could have been made using unsaved changes
68+
// and still appear "not dirty".
6569
yield break;
6670
}
6771

0 commit comments

Comments
 (0)