@@ -13,6 +13,7 @@ import { AuthProvider } from '../common/authentication';
1313import { Disposable } from '../common/lifecycle' ;
1414import Logger from '../common/logger' ;
1515import * as PersistentState from '../common/persistentState' ;
16+ import { GITHUB_ENTERPRISE , URI } from '../common/settingKeys' ;
1617import { ITelemetry } from '../common/telemetry' ;
1718import { agent } from '../env/node/net' ;
1819import { IAccount } from './interface' ;
@@ -213,8 +214,18 @@ export class CredentialStore extends Disposable {
213214 private async doCreate ( options : vscode . AuthenticationGetSessionOptions , additionalScopes : boolean = false ) : Promise < AuthResult > {
214215 const github = await this . initialize ( AuthProvider . github , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
215216 let enterprise : AuthResult | undefined ;
217+ const initializeEnterprise = ( ) => this . initialize ( AuthProvider . githubEnterprise , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
216218 if ( hasEnterpriseUri ( ) ) {
217- enterprise = await this . initialize ( AuthProvider . githubEnterprise , options , additionalScopes ? SCOPES_WITH_ADDITIONAL : undefined , additionalScopes ) ;
219+ enterprise = await initializeEnterprise ( ) ;
220+ } else {
221+ // Listen for changes to the enterprise URI and try again if it changes.
222+ const disposable = vscode . workspace . onDidChangeConfiguration ( async e => {
223+ if ( e . affectsConfiguration ( `${ GITHUB_ENTERPRISE } .${ URI } ` ) && hasEnterpriseUri ( ) ) {
224+ enterprise = await initializeEnterprise ( ) ;
225+ disposable . dispose ( ) ;
226+ }
227+ } ) ;
228+ this . context . subscriptions . push ( disposable ) ;
218229 }
219230 return {
220231 canceled : github . canceled || ! ! ( enterprise && enterprise . canceled )
0 commit comments