Repository navigation
Add task provider for R extension - #1445
Conversation
|
|
||
| export async function setContexts(_context: vscode.ExtensionContext): Promise<void> { | ||
| const isRPackage = await detectRPackage(); | ||
| vscode.commands.executeCommand('setContext', 'isRPackage', isRPackage); |
There was a problem hiding this comment.
Only one context for now, but we need it in multiple places and we can make more in the future.
| packageTask.name, | ||
| 'R', | ||
| new vscode.ShellExecution(packageTask.shellExecution), | ||
| [] |
There was a problem hiding this comment.
This is where problem matchers go. It's empty now, but we could do a lot of nice stuff with it.
| // For now, there will be only one running R runtime: | ||
| const runtimePath = runningRuntimes[0].runtimePath; | ||
| const allPackageTasks: PackageTask[] = [ | ||
| { 'name': 'Check R package', 'shellExecution': `${runtimePath}/R -e "devtools::check()"` } |
There was a problem hiding this comment.
We can add more package tasks here in this array moving forward.
|
This PR registers a task provider for the R extension that only provides one single task for now, but I tried to set it up to not be too hard to add more. I definitely think we'll add testing too. The existing
Is that what we want to do? We could just keep it as a task only (with a keybinding) and remove the command. |
jmcphers
left a comment
There was a problem hiding this comment.
I am somewhat concerned that it is too fragile to presume that R is online and running happily at the exact moment that VS Code invokes the task list method.
Since what we really need is the runtime path, I think it might be better to attach event handlers to the R runtimes as they are registered. The event handler can listen for start events and update a global variable that monitors the last-used runtime. Then your task provider can always register the relevant tasks regardless of what's going on with R at the moment.
| export async function getRPackageTasks(): Promise<vscode.Task[]> { | ||
| const runningRuntimes = await positron.runtime.getRunningRuntimes('r'); | ||
| // For now, there will be only one running R runtime: | ||
| const runtimePath = runningRuntimes[0].runtimePath; |
There was a problem hiding this comment.
We need to handle the case where there are zero runtimes available (which is possible if R is crashed and hasn't been restarted, etc.). I
Addresses #1303
Currently I'm just adding package check as a task, but this will be extensible for other tasks.