Fix multiconsole hyperlink support by treating pasteText() like executeCode()
#8148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #7322
Way back in #2027 I introduced
Consoletopositron.d.tswith the intended purpose of mimicking theTextEditorAPI, i.e.:Consoleis similar toTextEditorand is exposed to extension authorsExtHostConsole, similar toExtHostTextEditorMainThreadConsole, similar toMainThreadTextEditorExtHostConsolemirrors aMainThreadConsole, tied by a simple stringidpositron.d.tsmethods take or returnConsoles. With our only ones right now beingConsole.pasteText(), andpositron.window.getConsoleForLanguage(languageId: string): Thenable<Console | undefined>. These were our POC methods for that PR.I still think this feels like a decent way to handle this API, because it feels like you get a "real"
Consoleobject that you can invoke methods on.But this hasn't proven to be that useful yet. Instead, when we want to do something with a runtime or console we typically go through something like
positron.runtime.executeCode(languageId, code), i.e. we never get access to aConsoledirectly, we just invoke a method on whatever Positron deems to be the relevant one.For simplicity of API, I've decided to just remove the
ConsoleAPI for now in favor of implementingpasteText()in almost the same way we implementexecuteCode(), i.e. we now go directly throughpositron.runtime.pasteText(languageId, text). In fact, I've extracted out the "get or start a console/runtime for this language" behavior fromexecuteCode()into a helper so we can use the exact same behavior forpasteText(). This ends up addressing #7322 because this logic always selects the most relevant console, even in the multiconsole world.The two commits are self contained:
positron.runtime.pasteText(languageId, text)approachConsoleAPI, since it is no longer required