Remove session if it is being replaced (#212504)

A bug that has probably existed for quite a while... if we are replacing a session, we should say the old session is removed.
This commit is contained in:
Tyler James Leonhardt 2024-05-11 05:49:03 -07:00 committed by GitHub
parent bbc0159f43
commit 9d4274e559
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -306,14 +306,15 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid
this.afterSessionLoad(session);
const sessionIndex = sessions.findIndex(s => s.id === session.id || arrayEquals([...s.scopes].sort(), sortedScopes));
const removed = new Array<vscode.AuthenticationSession>();
if (sessionIndex > -1) {
sessions.splice(sessionIndex, 1, session);
removed.push(...sessions.splice(sessionIndex, 1, session));
} else {
sessions.push(session);
}
await this.storeSessions(sessions);
this._sessionChangeEmitter.fire({ added: [session], removed: [], changed: [] });
this._sessionChangeEmitter.fire({ added: [session], removed, changed: [] });
this._logger.info('Login success!');