@@ -11,6 +11,7 @@ import { Disposable, disposeAll } from '../common/lifecycle';
1111import Logger from '../common/logger' ;
1212import { ITelemetry } from '../common/telemetry' ;
1313import { EventType } from '../common/timelineEvent' ;
14+ import { fromRepoUri , Schemes } from '../common/uri' ;
1415import { compareIgnoreCase , isDescendant } from '../common/utils' ;
1516import { CredentialStore } from './credentials' ;
1617import { FolderRepositoryManager , ReposManagerState , ReposManagerStateContext } from './folderRepositoryManager' ;
@@ -132,18 +133,25 @@ export class RepositoriesManager extends Disposable {
132133 return this . _folderManagers [ 0 ] ;
133134 }
134135
136+ const repoInfo = ( ( uri . scheme === Schemes . Repo ) ? fromRepoUri ( uri ) : undefined ) ;
137+
135138 // Prioritize longest path first to handle nested workspaces
136139 const folderManagers = this . _folderManagers
137140 . slice ( )
138141 . sort ( ( a , b ) => b . repository . rootUri . path . length - a . repository . rootUri . path . length ) ;
139142
140143 for ( const folderManager of folderManagers ) {
141144 const managerPath = folderManager . repository . rootUri . path ;
142- const testUriRelativePath = uri . path . substring (
143- managerPath . length > 1 ? managerPath . length + 1 : managerPath . length ,
144- ) ;
145- if ( compareIgnoreCase ( vscode . Uri . joinPath ( folderManager . repository . rootUri , testUriRelativePath ) . path , uri . path ) === 0 ) {
145+
146+ if ( repoInfo && folderManager . findExistingGitHubRepository ( { owner : repoInfo . owner , repositoryName : repoInfo . repo } ) ) {
146147 return folderManager ;
148+ } else {
149+ const testUriRelativePath = uri . path . substring (
150+ managerPath . length > 1 ? managerPath . length + 1 : managerPath . length ,
151+ ) ;
152+ if ( compareIgnoreCase ( vscode . Uri . joinPath ( folderManager . repository . rootUri , testUriRelativePath ) . path , uri . path ) === 0 ) {
153+ return folderManager ;
154+ }
147155 }
148156 }
149157 return undefined ;
0 commit comments