-
Notifications
You must be signed in to change notification settings - Fork 108
Fix multiconsole hyperlink support by tracking active sessions in MainThreadConsoleService
#8151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… per language basis
A no-op for now, but `MainThreadConsoleService` should call it when consoles are deleted
…eInstance()` exists!
E2E Tests 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/positron-dts/positron.d.ts
Outdated
* | ||
* @param languageId The runtime language id to retrieve a `Console` for, i.e. 'r' or 'python'. | ||
* | ||
* @returns A Thenable that resolves to a `Console` or `undefined` if no `Console` for | ||
* that `languageId` exists. | ||
*/ | ||
export function getConsoleForLanguage(languageId: string): Thenable<Console | undefined>; | ||
export function getActiveConsoleForLanguage(languageId: string): Thenable<Console | undefined>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clearer, but do you think there's any chance someone is using the current name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I can see https://github.com/search?q=getConsoleForLanguage&type=code
@@ -48,7 +48,7 @@ function handleNotRunnable(code: string) { | |||
} | |||
|
|||
async function handleManuallyRunnable(_runtime: RSession, code: string) { | |||
const console = await positron.window.getConsoleForLanguage('r'); | |||
const console = await positron.window.getActiveConsoleForLanguage('r'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your change is fine, but since we have an RSession
, we could do this w/o any additional accounting by having an API to get a console by session ID instead of trying to track the active console
Plan for when I'm back from vacation:
|
Addresses #7322
Closes #8148 (an alternative approach)
As I was writing up #8148, I was irked by two things:
Console
object at the API level feels right and useful, and it mimics theTextEditor
API very closely.Console
In light of that, I no longer want to do the approach in #8148, because I think we should keep the
Console
API around, even if right now we only use it forpasteText()
.This PR uses the new-ish
onDidChangeActivePositronConsoleInstance()
event to allowMainThreadConsoleService
to track the active console per language. This allowspositron.window.getActiveConsoleForLanguage()
to correctly retrieve the active console given a particularlanguageId
. That addresses #7322 by allowing us to paste into the active console, rather than the first one the user ever created for that language.I also see that we now have
onDidDeletePositronConsoleInstance()
, so I've used that to also remove some TODOs about cleaning up when consoles are deleted.example.mov