Run preview and render as tasks with `ShellExecution`, so VS Code quotes arguments for the shell
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 42/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- typescript, vscode
- Domaine
- developer-experience, tooling
Piste de recherche
Start with apps/vscode/src/providers/render.ts and trace how it creates a terminal, sends the render command, and removes the terminal. Move render to a VS Code task using ShellExecution and ShellQuotedString, then check how task execution handles conda and venv activation. Done means render works with those environments and arguments containing spaces or shell metacharacters are passed correctly; preview migration is a separate, more involved part of the issue.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
The extension runs Quarto for preview and render with terminal.sendText(). It builds the command line itself, so it must quote each argument for the shell that the terminal starts. In #1197, we are correcting some reported problems (#1194, #1102, posit-dev/positron#15907) by getting the shell from vscode.env.shell and quoting for bash, zsh, sh, PowerShell, and cmd. However, this approach still guesses which shell reads the command line.
I'd like to propose to run these commands as tasks with ShellExecution, and to give the arguments as ShellQuotedString values. Then the task system finds the shell and quotes each argument for that shell. Positron uses this approach, and it works well there.
Problems that remain with the current approach
- The extension knows only bash, zsh, sh, PowerShell, and cmd. For all other shells (for example fish, nu, and WSL), it quotes only on whitespace. As a result, paths with parentheses,
;, or$still break in these shells. For example, fish runs(md)as a command substitution. vscode.env.shellgives the default profile at the time that the extension sends the command. This shell is not always the shell that the terminal runs.- With
useCmd(Quarto 1.1.162 and earlier on Windows), the extension quotes the path for cmd.exe and puts the line incmd /C"...". But the extension types this line into the default shell of the user, which is often PowerShell. - The extension quotes only the document path. It does not quote the other arguments. For example, R package preview adds
--output-dir <temp dir>with no quotes, so a Windows user name with a space breaks the preview.
Scope of the change
Render (apps/vscode/src/providers/render.ts) would be the best place to start. It makes a terminal, sends the command, and removes the terminal by name before the next render. No other code tracks this terminal.
Preview (apps/vscode/src/providers/preview/preview.ts) needs more work, because its design uses a Terminal object:
- It keeps
this.terminal_, readsexitStatus, callsshow(), and usesonDidCloseTerminalto send the terminate request. - The Positron Viewer stop button (#1193) uses
onDidEndTerminalShellExecutionfor that terminal. After the user stops the preview, the terminal stays open, so the user can read the output. killTerminal()finds the terminal by its name.
A task gives a TaskExecution, not a Terminal. Thus this lifecycle must move to tasks.onDidStartTaskProcess, tasks.onDidEndTaskProcess, and TaskExecution.terminate().
Open questions
- Python environment activation: before it types the command,
sendTerminalCommand()waits up to 5 seconds for venv or conda activation. How does activation work in task terminals, in VS Code and in Positron? - After the user stops the preview, can a task terminal keep its output visible, as the stop button does now?
- Can we remove the
useCmdpath? It applies only to Quarto 1.1.162 and earlier.
Proposed plan
- Move render to
ShellExecution. Do a test with conda and venv environments. - Move preview, with the stop button and the restart behavior, in VS Code and in Positron.
- When no code uses them, remove the shell detection and quoting from
terminalCommand()(shQuote(),shQuoteUnknownShell(),terminalShellForPath()).
- Langage dominant
- TypeScript
- Étoiles
- 665
- Forks
- 69
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 14
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de quarto-dev/quarto
-
vscode
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
quarto-dev/quarto#1227 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug vscode
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
quarto-dev/quarto#1211 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
quarto-dev/quarto#1139 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 1-3 heures Accessibilité débutants 90/100
quarto-dev/quarto#1138 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
quarto-dev/quarto#1137 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de quarto-dev/quarto
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
genfeedai/genfeed.ai#11828 ·
Les mainteneurs répondent en général sous 1 jour
-
bug security
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
IbrahimHafez1/loadwise#251 ·
Les mainteneurs répondent en général sous 1 jour
-
bug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
erkamyaman/unslop-anything#415 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Yeachan-Heo/oh-my-codex#4278 ·
Les mainteneurs répondent en général sous 1 jour
-
admin
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour