Skip to content

Commit

Permalink
Updated logic to select next available session if no sessions of the …
Browse files Browse the repository at this point in the history
…same runtime exist
  • Loading branch information
samclark2015 committed Feb 26, 2025
1 parent 97dcaa5 commit c835e33
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,25 @@ export class PositronConsoleService extends Disposable implements IPositronConso

this._onDidDeletePositronConsoleInstanceEmitter.fire(consoleInstance);

let runtimeSession = this._runtimeSessionService.getConsoleSessionForRuntime(
consoleInstance.session.runtimeMetadata.runtimeId
);
if (!runtimeSession) {
// Otherwise, select the next available runtime session.
const sessions = Array.from(this._positronConsoleInstancesBySessionId.values());
const currentIndex = sessions.indexOf(consoleInstance);
if (currentIndex !== -1) {
const nextSession = sessions[currentIndex + 1] || sessions[currentIndex - 1];
runtimeSession = nextSession?.session;
}
}
this._runtimeSessionService.foregroundSession = runtimeSession;

this._positronConsoleInstancesByLanguageId.delete(
consoleInstance.session.runtimeMetadata.languageId
);
this._positronConsoleInstancesBySessionId.delete(sessionId);

if (this._positronConsoleInstancesBySessionId.size === 0) {
this._runtimeSessionService.foregroundSession = undefined;
} else {
const runtimeSession = this._runtimeSessionService.getConsoleSessionForRuntime(
consoleInstance.session.runtimeMetadata.runtimeId
);
this._runtimeSessionService.foregroundSession = runtimeSession;
}


consoleInstance.dispose();
}));
}
Expand Down

0 comments on commit c835e33

Please sign in to comment.