posit-dev / positron

Positron, a next-generation data science IDE
Other
1.97k stars 59 forks source link

R language runtime emits a single \n (newline) when interrupted... #1238

Open softwarenerd opened 10 months ago

softwarenerd commented 10 months ago

When you execute a long-running statement in R and then interrupt it via Ctrl-C (or escape), the onDidReceiveRuntimeMessageStream event is fired on the stderr stream with a \n (newline). This results in a blank line of error output in the console:

Image

This does not happen in RStudio:

I Ctrl-C'd this sleep in RStudio:

Image

Set a breakpoint here on addOrUpdateUpdateRuntimeItemActivity to see the output:

            } else if (languageRuntimeMessageStream.name === 'stderr') {
                this.addOrUpdateUpdateRuntimeItemActivity(
                    languageRuntimeMessageStream.parent_id,
                    new ActivityItemErrorStream(
                        languageRuntimeMessageStream.id,
                        languageRuntimeMessageStream.parent_id,
                        new Date(languageRuntimeMessageStream.when),
                        languageRuntimeMessageStream.text
                    )
                );
            }
jmcphers commented 10 months ago

Is this the same as https://github.com/posit-dev/positron/issues/1222?

DavisVaughan commented 10 months ago

I have managed to track this down to something being emitted by R itself https://github.com/wch/r-source/blob/819477cd6dbefb8fae61a07fc13064faa29a2714/src/main/errors.c#L188

RStudio also knows about it and tries to suppress it: https://github.com/rstudio/rstudio/pull/7982#discussion_r500745047 https://github.com/rstudio/rstudio/pull/7982/commits/3f239473babc0182c780d937239179fbf86da1a3

We can probably do a similar thing to suppress this new line from coming through, I'll try and look into it