@@ -119,8 +119,12 @@ public async Task<ITextView> OpenFile(
119119
120120 if ( ! workingDirectory )
121121 {
122- AddBufferTag ( wpfTextView . TextBuffer , session , fullPath , commitSha , null ) ;
123- EnableNavigateToEditor ( textView , session ) ;
122+ var gitPath = FindGitPath ( session . LocalRepository , fullPath ) ;
123+ if ( gitPath != null )
124+ {
125+ AddBufferTag ( wpfTextView . TextBuffer , session , gitPath , commitSha , null ) ;
126+ EnableNavigateToEditor ( textView , session ) ;
127+ }
124128 }
125129 }
126130
@@ -485,6 +489,17 @@ static string GetAbsolutePath(LocalRepositoryModel localRepository, string relat
485489 return Path . Combine ( localPath , relativePath ) ;
486490 }
487491
492+ static string FindGitPath ( LocalRepositoryModel localRepository , string path )
493+ {
494+ var basePath = localRepository . LocalPath + Path . DirectorySeparatorChar ;
495+ if ( path . StartsWith ( basePath , StringComparison . OrdinalIgnoreCase ) )
496+ {
497+ return path . Substring ( basePath . Length ) . Replace ( Path . DirectorySeparatorChar , '/' ) ;
498+ }
499+
500+ return null ;
501+ }
502+
488503 string GetText ( IVsTextView textView )
489504 {
490505 IVsTextLines buffer ;
@@ -561,21 +576,23 @@ void ShowErrorInStatusBar(string message, Exception e)
561576 void AddBufferTag (
562577 ITextBuffer buffer ,
563578 IPullRequestSession session ,
564- string path ,
579+ string gitPath ,
565580 string commitSha ,
566581 DiffSide ? side )
567582 {
583+ Guard . ArgumentIsGitPath ( gitPath , nameof ( gitPath ) ) ;
584+
568585 buffer . Properties . GetOrCreateSingletonProperty (
569586 typeof ( PullRequestTextBufferInfo ) ,
570- ( ) => new PullRequestTextBufferInfo ( session , path , commitSha , side ) ) ;
587+ ( ) => new PullRequestTextBufferInfo ( session , gitPath , commitSha , side ) ) ;
571588
572589 var projection = buffer as IProjectionBuffer ;
573590
574591 if ( projection != null )
575592 {
576593 foreach ( var source in projection . SourceBuffers )
577594 {
578- AddBufferTag ( source , session , path , commitSha , side ) ;
595+ AddBufferTag ( source , session , gitPath , commitSha , side ) ;
579596 }
580597 }
581598 }
0 commit comments