Skip to content
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

Update 'workbench.action.positronConsole.executeCode' to be used in Quarto #3107

Merged
merged 7 commits into from
May 22, 2024

Conversation

juliasilge
Copy link
Contributor

Intent

Addresses #1518
Goes together with quarto-dev/quarto#436

Approach

I'm putting this up as draft for some discussion, and I'll add some notes to point out the current challenges.

QA Notes

When we QA this change, we'll want to use the current development version of the Quarto extension (download .vsix from https://github.com/quarto-dev/quarto) and check out the statement-by-statement execution in Quarto chunks.

Copy link
Contributor Author

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is currently sort of half of a solution. The remaining challenge is that provideStatementRange() takes as an argument a model (because we implemented these as a LanguageFeatureRegistry). Our statement range provider doesn't know what to do with an ITextModel for a Quarto file; it fails in different ways for languageId = "r" as languageId = "quarto" but either way, it cannot currently identify the current statement.

I am wondering if we can do some parsing in ark to make a little fake document of the current chunk, much like we did parsing for roxygen comments. I believe it would be much easier to do it in ark than here in Positron or in the Quarto extension, because of how the VS Code types are being passed around.

@@ -269,7 +269,7 @@ export function registerPositronConsoleActions() {
* Runs action.
* @param accessor The services accessor.
*/
async run(accessor: ServicesAccessor, opts: { allowIncomplete?: boolean } = {}) {
async run(accessor: ServicesAccessor, opts: { allowIncomplete?: boolean; languageId?: string } = {}) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Quarto extension knows what language we are using and can send it over in opts.

@@ -499,7 +510,7 @@ export function registerPositronConsoleActions() {
}

// Now that we've gotten this far, ensure we have a target language.
const languageId = editorService.activeTextEditorLanguageId;
const languageId = opts.languageId ? opts.languageId : editorService.activeTextEditorLanguageId;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update here to get the console to execute it in the correct runtime.

@juliasilge
Copy link
Contributor Author

It would be great to get some feedback on this Monday when you get online @DavisVaughan.

@juliasilge
Copy link
Contributor Author

This is getting there, together with the changes in quarto-dev/quarto#436 so that Quarto can register a statement range provider, to then in turn call the correct statement range provider for the document's language via a command.

@juliasilge juliasilge marked this pull request as ready for review May 21, 2024 20:50
Comment on lines 56 to 61
if (!result) {
// there is no provider or it didn't return a statement range
return undefined;
}

return result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC correctly you can just return result unconditionally. It is either a real IStatementRange or undefined, both of which are the expected return value of this function

src/vs/workbench/api/common/extHostApiCommands.ts Outdated Show resolved Hide resolved
juliasilge and others added 2 commits May 22, 2024 08:01
@juliasilge juliasilge merged commit 1463261 into main May 22, 2024
1 check passed
@juliasilge juliasilge deleted the statement-range-execution-for-quarto branch May 22, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants