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

Negotiate terms re: Ctrl+Enter/Cmd+Enter with the Quarto extension #1518

Closed
jennybc opened this issue Oct 6, 2023 · 9 comments
Closed

Negotiate terms re: Ctrl+Enter/Cmd+Enter with the Quarto extension #1518

jennybc opened this issue Oct 6, 2023 · 9 comments
Assignees
Labels
area: quarto Issues related to Quarto category.

Comments

@jennybc
Copy link
Member

jennybc commented Oct 6, 2023

I am someone who, apparently, has used Ctrl+Enter for years to run 1 line of R code in RStudio, as opposed to Cmd+Enter, even though I'm on macOS.

This works in Positron as of #1209.

I just tried (and failed) to use Ctrl+Enter to run a line of R code from a vignette, where we're getting .Rmd support from the Quarto extension. That leads to a rather puzzling refusal:

Screenshot 2023-10-06 at 8 29 45 AM

Puzzling because I am staring at a perfectly healthy R runtime and I can run whole chunks. Of course what I should do is use Cmd+Enter, which works!

Slack discussion lead to this issue.

@jmcphers says:

When the Quarto extension is run in Positron, it'd be preferable if it didn't register Cmd+Enter at all, because we want our Cmd+Enter from Positron to be used instead (as it is now very smart about running statements vs. lines, etc.)

Of course, we'd first need to fix our Cmd+Enter/Ctrl+Enter function so it can pick up the embedded language at the cursor position vs. the editor language.

Capturing (some of) what Positron > Settings > Keyboard shortcuts shows for me right now, which also illustrates the problem:

Screenshot 2023-10-06 at 8 59 26 AM Screenshot 2023-10-06 at 9 00 05 AM
@jennybc
Copy link
Member Author

jennybc commented Oct 6, 2023

From @jjallaire:

Another way to do this is that the Quarto extension has the concept of execution back ends that know how to intelligently execute statements (this actually works with the current VS Code R extension). So if you provide an API that is executeStatement() which takes no arguments then I can call that and it will all work.

@jennybc jennybc changed the title Negotiate Ctrl+enter/Cmd+enter terms with the Quarto extension Negotiate terms re: Ctrl+Enter/Cmd+Enter with the Quarto extension Oct 6, 2023
@jennybc
Copy link
Member Author

jennybc commented Feb 23, 2024

The behaviour I originally noted is still present.

@jennybc jennybc added this to the Public Beta 2024 Q2 milestone Feb 23, 2024
@wesm wesm added the area: quarto Issues related to Quarto category. label Feb 29, 2024
@jmcphers
Copy link
Collaborator

feedback from @EmilHvitfeldt via @juliasilge:

He uses Quarto a lot and really feels the pain around the lack of keyboard shortcuts and inability to use Cmd + Enter to send code from a Quarto chunk to the console. The Quarto experience feels a lot more rough than the R package development experience.

https://positpbc.slack.com/archives/C04FPQK3H9C/p1710266024900919

@jmcphers
Copy link
Collaborator

jmcphers commented Apr 4, 2024

Came up in beta feedback too: https://github.com/posit-dev/positron-beta/discussions/71

@jmcphers
Copy link
Collaborator

jmcphers commented May 7, 2024

Toehold: Here's where Quarto's executor connects to the vscode-R extension to trigger statement-aware execution.

https://github.com/quarto-dev/quarto/blob/0e27dc40a96044979bf1fdf1b34a2857ded3b21b/apps/vscode/src/host/executors.ts#L84-L95

@jjallaire
Copy link
Contributor

Here is where we call Positron: https://github.com/quarto-dev/quarto/blob/0e27dc40a96044979bf1fdf1b34a2857ded3b21b/apps/vscode/src/host/hooks.ts#L54-L69

You just need to implement an executeSelection() method there that tells Positron to do statement aware execution and everything should just work (that's effectively what we do for the VS Code R Extension in the code Jonathan linked to above).

@juliasilge
Copy link
Contributor

Two PRs so far:

I currently believe we'll need to also update the statement range provider in ark, and then also look at the Python experience. So basically, you know, everything. 😩

@juliasilge
Copy link
Contributor

juliasilge commented May 23, 2024

This is now ready for verification for Public Beta. For QA and confirming that we have the behavior as expected now, one will need to install the .vsix for the Quarto extension generated via GH Action artifact, like the one on this page (download the artifact, unzip, install in Positron via "Extensions: Install from VSIX..."). If you open a Quarto file with R chunks only (see below), you can now step through statements in chunks via Cmd+Enter.

  • This only works for Cmd+Enter for Mac, and not Ctrl+Enter. If we do want to support that as well, we'll need to make another change to the Quarto extension similar to Allow Ctrl+Enter to also execute code #1209 here. I don't know how open they will be to this and I'm not sure how common this behavior is for Mac users.
  • Only R Quarto files are going through Positron's statement range provider. Python Quarto files are going through the Jupyter executors from the Quarto extension still and the behavior is slightly different. That may be preferable for Python users but we can open a followup issue if folks have opinions. (This would involve changes to the Quarto VS Code extension, not Positron.)
  • Quarto files with mixed R and Python chunks have some remaining issues but are mostly functional because they go through knitr and reticulate. The behavior could be improved but I do not think this is important for Public Beta.

@lionel-
Copy link
Contributor

lionel- commented May 28, 2024

Now works great!

Screen.Recording.2024-05-28.at.17.02.52.mov

@lionel- lionel- closed this as completed May 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: quarto Issues related to Quarto category.
Projects
None yet
Development

No branches or pull requests

6 participants