posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.58k stars 79 forks source link

How is multiline code executed? #1762

Open softwarenerd opened 11 months ago

softwarenerd commented 11 months ago

In RStudio, if I select four lines of code and press ⌘-Enter:

Image

It executes four separate one-line statements.

If I do the same thing in Positron:

Image

It executes one statement with four lines of code.

Is this what we want?

jmcphers commented 11 months ago

RStudio's behavior is controversial; people do not universally love it. Sometimes people want everything in one chunk so it navigates well in the History. Sometimes they want it in individual lines so they can see the output of each one. Sometimes they want it to run a line at a time so that we can discard pending lines after an error. We implemented that, and it made people frustrated. We eventually had to make an option or two because there are subtle tradeoffs here. See https://github.com/rstudio/rstudio/issues/13848, https://github.com/rstudio/rstudio/issues/3520, https://github.com/rstudio/rstudio/issues/3014.

My personal vote would be for something like the following:

An advantage Positron has over RStudio is that that in RStudio the queue is more or less invisible since it's sitting in a buffer attached to the R session. In Positron we can show you exactly what's submitted, what's currently executing, and what's up next to be executed. We might also provide affordances to removing stuff from the queue, or interactively entering a new statement to be executed next. But all that's probably not worth investing in for Internal Preview.

DavisVaughan commented 11 months ago

This is directly related to https://github.com/posit-dev/positron/issues/1326#issuecomment-1745389921 - we really need this when sending large amounts of input over to R, because the maximum console input length for R is 4096 bytes, and currently if you select a whole script (with CMD + A) and try to execute the whole thing at once, the entire script is sent over at once, which is likely to overflow that buffer.

lionel- commented 6 months ago

Also brought by a beta user in https://github.com/posit-dev/positron-beta/discussions/86 in the context of selections made with multiple cursors. It looks like only the first selection is executed in that case, which seems like a bug? We'd probably want that behaviour to match a single selection of multiple lines?

juliasilge commented 2 months ago

I think that #3915 is an example of problems with our current approach. I'm moving this to triage so we can talk about when to work on it, and I am labeling it a bug since our users are perceiving the effects of the current approach as so unexpected as to be bugs.