@@ -11,6 +11,7 @@ import { Disposable, disposeAll } from '../common/lifecycle';
11
11
import Logger from '../common/logger' ;
12
12
import { ITelemetry } from '../common/telemetry' ;
13
13
import { EventType } from '../common/timelineEvent' ;
14
+ import { fromRepoUri , Schemes } from '../common/uri' ;
14
15
import { compareIgnoreCase , isDescendant } from '../common/utils' ;
15
16
import { CredentialStore } from './credentials' ;
16
17
import { FolderRepositoryManager , ReposManagerState , ReposManagerStateContext } from './folderRepositoryManager' ;
@@ -132,18 +133,25 @@ export class RepositoriesManager extends Disposable {
132
133
return this . _folderManagers [ 0 ] ;
133
134
}
134
135
136
+ const repoInfo = ( ( uri . scheme === Schemes . Repo ) ? fromRepoUri ( uri ) : undefined ) ;
137
+
135
138
// Prioritize longest path first to handle nested workspaces
136
139
const folderManagers = this . _folderManagers
137
140
. slice ( )
138
141
. sort ( ( a , b ) => b . repository . rootUri . path . length - a . repository . rootUri . path . length ) ;
139
142
140
143
for ( const folderManager of folderManagers ) {
141
144
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 } ) ) {
146
147
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
+ }
147
155
}
148
156
}
149
157
return undefined ;
0 commit comments