Skip to content

Commit

Permalink
Use newest console instance for code execution
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvisompura committed Feb 27, 2025
1 parent 588d68a commit 92e094a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,13 @@ export class PositronConsoleService extends Disposable implements IPositronConso
// Return the active console instance for the language if there is one
positronConsoleInstance = this._positronConsoleInstancesBySessionId.get(this._activePositronConsoleInstance?.session.sessionId);
} else {
// Otherwise find a session for the languageId that is ready to use
positronConsoleInstance = Array.from(this._positronConsoleInstancesBySessionId.values()).find(consoleInstance => {
return consoleInstance.session.runtimeMetadata.languageId === languageId && consoleInstance.state === PositronConsoleState.Ready;
});
// Otherwise find the newest session for the languageId that is ready to use
positronConsoleInstance = Array.from(this._positronConsoleInstancesBySessionId.values())
.sort((a, b) => b.session.metadata.createdTimestamp - a.session.metadata.createdTimestamp)
.find(consoleInstance => {
return consoleInstance.session.runtimeMetadata.languageId === languageId &&
consoleInstance.state === PositronConsoleState.Ready;
});
}
}

Expand Down

0 comments on commit 92e094a

Please sign in to comment.