@@ -1193,7 +1193,7 @@ export class GitService extends Disposable {
11931193 if ( filePathOrUri instanceof GitUri ) return filePathOrUri . repoPath ;
11941194
11951195 // Don't save the tracking info to the cache, because we could be looking in the wrong place (e.g. looking in the root when the file is in a submodule)
1196- const repo = await this . getRepository ( filePathOrUri , { ...options , skipCacheUpdate : true } ) ;
1196+ let repo = await this . getRepository ( filePathOrUri , { ...options , skipCacheUpdate : true } ) ;
11971197 if ( repo !== undefined ) return repo . path ;
11981198
11991199 if ( typeof filePathOrUri !== 'string' ) {
@@ -1209,21 +1209,24 @@ export class GitService extends Disposable {
12091209
12101210 // If this new repo is inside one of our known roots and we we don't already know about, add it
12111211 const root = this . _repositoryTree . findSubstr ( rp ) ;
1212- const folder = root === undefined
1212+ let folder = root === undefined
12131213 ? workspace . getWorkspaceFolder ( Uri . file ( rp ) )
12141214 : root . folder ;
12151215
1216- if ( folder !== undefined ) {
1217- const repo = new Repository ( folder , rp , false , this . onAnyRepositoryChanged . bind ( this ) , this . _suspended ) ;
1218- this . _repositoryTree . set ( rp , repo ) ;
1216+ if ( folder === undefined ) {
1217+ const parts = rp . split ( '/' ) ;
1218+ folder = { uri : Uri . file ( rp ) , name : parts [ parts . length - 1 ] , index : this . _repositoryTree . count ( ) } ;
1219+ }
12191220
1220- // Send a notification that the repositories changed
1221- setImmediate ( async ( ) => {
1222- await this . updateContext ( this . _repositoryTree ) ;
1221+ repo = new Repository ( folder , rp , false , this . onAnyRepositoryChanged . bind ( this ) , this . _suspended ) ;
1222+ this . _repositoryTree . set ( rp , repo ) ;
12231223
1224- this . fireRepositoriesChanged ( ) ;
1225- } ) ;
1226- }
1224+ // Send a notification that the repositories changed
1225+ setImmediate ( async ( ) => {
1226+ await this . updateContext ( this . _repositoryTree ) ;
1227+
1228+ this . fireRepositoriesChanged ( ) ;
1229+ } ) ;
12271230
12281231 return rp ;
12291232 }
0 commit comments