From 9d4274e5599f6ba2c667a54ec0d1d6594d30145b Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Sat, 11 May 2024 05:49:03 -0700 Subject: [PATCH] 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. --- extensions/github-authentication/src/github.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/github-authentication/src/github.ts b/extensions/github-authentication/src/github.ts index c603455facf..15fe2ef04f8 100644 --- a/extensions/github-authentication/src/github.ts +++ b/extensions/github-authentication/src/github.ts @@ -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(); 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!');