@@ -4,7 +4,7 @@ import { ConfigurationChangeEvent, Disposable, Event, EventEmitter, Range, TextE
44import { configuration , IRemotesConfig } from './configuration' ;
55import { CommandContext , DocumentSchemes , setCommandContext } from './constants' ;
66import { Container } from './container' ;
7- import { CachedBlame , CachedDiff , CachedLog , DocumentTracker , GitDocumentState , TrackedDocument } from './trackers/documentTracker' ;
7+ import { CachedBlame , CachedDiff , CachedLog , GitDocumentState , TrackedDocument } from './trackers/documentTracker' ;
88import { RemoteProviderFactory , RemoteProviderMap } from './git/remotes/factory' ;
99import { CommitFormatting , Git , GitAuthor , GitBlame , GitBlameCommit , GitBlameLine , GitBlameLines , GitBlameParser , GitBranch , GitBranchParser , GitCommit , GitCommitType , GitDiff , GitDiffChunkLine , GitDiffParser , GitDiffShortStat , GitLog , GitLogCommit , GitLogParser , GitRemote , GitRemoteParser , GitStash , GitStashParser , GitStatus , GitStatusFile , GitStatusParser , GitTag , GitTagParser , IGit , Repository } from './git/git' ;
1010import { GitUri , IGitCommitInfo } from './git/gitUri' ;
@@ -45,12 +45,14 @@ export class GitService extends Disposable {
4545 private _repositoriesLoadingPromise : Promise < void > | undefined ;
4646 private _suspended : boolean = false ;
4747 private readonly _trackedCache : Map < string , boolean | Promise < boolean > > ;
48+ private _versionedUriCache : Map < string , GitUri > ;
4849
4950 constructor ( ) {
5051 super ( ( ) => this . dispose ( ) ) ;
5152
5253 this . _repositoryTree = TernarySearchTree . forPaths ( ) ;
5354 this . _trackedCache = new Map ( ) ;
55+ this . _versionedUriCache = new Map ( ) ;
5456
5557 this . _disposable = Disposable . from (
5658 window . onDidChangeWindowState ( this . onWindowStateChanged , this ) ,
@@ -65,6 +67,7 @@ export class GitService extends Disposable {
6567 dispose ( ) {
6668 this . _repositoryTree . forEach ( r => r . dispose ( ) ) ;
6769 this . _trackedCache . clear ( ) ;
70+ this . _versionedUriCache . clear ( ) ;
6871
6972 this . _disposable && this . _disposable . dispose ( ) ;
7073 }
@@ -684,11 +687,6 @@ export class GitService extends Disposable {
684687 return await Git . config_get ( key , repoPath ) ;
685688 }
686689
687- async getGitUri ( uri : Uri ) {
688- const doc = await Container . tracker . get ( uri ) ;
689- return doc !== undefined ? doc . uri : undefined ;
690- }
691-
692690 async getDiffForFile ( uri : GitUri , sha1 ?: string , sha2 ?: string ) : Promise < GitDiff | undefined > {
693691 if ( sha1 !== undefined && sha2 === undefined && uri . sha !== undefined ) {
694692 sha2 = uri . sha ;
@@ -1201,6 +1199,10 @@ export class GitService extends Disposable {
12011199 }
12021200
12031201 const file = await Git . getVersionedFile ( repoPath , fileName , sha ) ;
1202+ if ( file === undefined ) return undefined ;
1203+
1204+ this . _versionedUriCache . set ( GitUri . toKey ( file ) , new GitUri ( Uri . file ( fileName ) , { sha : sha , repoPath : repoPath ! , versionedPath : file } ) ) ;
1205+
12041206 return file ;
12051207 }
12061208
@@ -1210,6 +1212,10 @@ export class GitService extends Disposable {
12101212 return Git . show ( repoPath , fileName , sha , { encoding : GitService . getEncoding ( repoPath , fileName ) } ) ;
12111213 }
12121214
1215+ getVersionedUri ( uri : Uri ) {
1216+ return this . _versionedUriCache . get ( GitUri . toKey ( uri ) ) ;
1217+ }
1218+
12131219 isTrackable ( scheme : string ) : boolean ;
12141220 isTrackable ( uri : Uri ) : boolean ;
12151221 isTrackable ( schemeOruri : string | Uri ) : boolean {
@@ -1233,15 +1239,15 @@ export class GitService extends Disposable {
12331239 let fileName : string ;
12341240 if ( typeof fileNameOrUri === 'string' ) {
12351241 [ fileName , repoPath ] = Git . splitPath ( fileNameOrUri , repoPath ) ;
1236- cacheKey = DocumentTracker . toStateKey ( fileNameOrUri ) ;
1242+ cacheKey = GitUri . toKey ( fileNameOrUri ) ;
12371243 }
12381244 else {
12391245 if ( ! this . isTrackable ( fileNameOrUri ) ) return false ;
12401246
12411247 fileName = fileNameOrUri . fsPath ;
12421248 repoPath = fileNameOrUri . repoPath ;
12431249 sha = fileNameOrUri . sha ;
1244- cacheKey = DocumentTracker . toStateKey ( fileName ) ;
1250+ cacheKey = GitUri . toKey ( fileName ) ;
12451251 }
12461252
12471253 if ( sha !== undefined ) {
0 commit comments