Sending single line to active terminal does not look laggy, but sending tens of lines look very laggy.
var1 <- 1
var2 <- 2
var3 <- 3
res <- local({
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
var1 + var2 + var3
})

Sending a hundred lines of code could take about 30 seconds.
This occurs on both of my MacBook Pro and Ubuntu desktop machine, both are powerful enough in hardware.
Strangely, under Remote Developement, I don't observe this laggy behavior.
I turn off the bracketed paste mode and the code sending become much faster. And I turn it on again and send code to R (instead of radian), I can clearly see the code sending is extremely slow.

@renkun-ken I've noticed this as well. Thank you for identifying it as being related to bracketed paste mode. I want to do a PR this week for #117 which will send code as one string instead of line by line when using bracketed paste mode. Hopefully that will take care of this problem as well.
The problem is fixed by #117. Thanks!
Reopening as unfortunately I鈥檓 experiencing this in normal R terminals too with bracketed paste mode disabled. That won鈥檛 be fixed by #149.
Based on the timing, I suspect I caused the problem with #141.
@andycraig I did not publish new version yet. Is it related?
@Ikuyadeu No, the new version will only solve the problem for bracketed paste mode (e.g., with radian). Bracketed paste mode does not work well with normal R, so the new version will not solve that problem.
@andycraig Thank you for the early reply.
BTW I plan to publish a new version after reviewing the new PR. Should I keep until solving this issue?
I've just duplicated this issue with vscode-R version 0.6.1 from over a year ago! Now I'm wondering if something has changed in the VSCode API...
@Ikuyadeu I think it's okay to go ahead and publish a new version. It's hard to guess how long this will take to fix.
The issue goes away with VSCode 1.39.2.
It seems that this issue is caused by VSCode version 1.40.
I will have a look at the release notes for VSCode 1.40 and see if I can figure out what the problem is.
A couple of solutions that DON'T work:
delay in vscode-R's runTextInTerm() functionI'm not seeing this issue at all with radian. Has it been resolved?
@vnijs It shouldn鈥檛 be an issue with radian if bracketed paste mode is on. In normal R with bracketed paste mode off, it still occurs for me if I use VSCode 1.40 or 1.41 but is fine with VSCode 1.39. For that reason I think it鈥檚 due to a slowdown in VSCode itself, so I鈥檓 planning to open an issue there.
Are there any news or is there an official issue for this in VSCode? I have recently started using VSCode for R programming and found this to be the main annoyance when switching from RStudio. I am not using radian (yet).
EDIT: Just now that I finally wrote this comment I found it to be less of an issue now? Sending 160 lines of codes does now take ~1.8 seconds in VScode (and ~0.2 seconds in RStudio). I did not measure the execution times before but could swear that it was much worse just a week ago?
Hi @NeuKon, I still haven鈥檛 opened that issue at VSCode. I definitely recommend radian, as it doesn鈥檛 have this problem and is also much better than the ordinary R console in many other ways.
It鈥檚 possible it might have improved with the latest VSCode release on May 8.
I've just tried sending ~160 lines of code with VSCode version 1.45 on Windows and Ubuntu, and it does seem much faster than with version 1.40. It's smooth enough again that I think we can consider this issue resolved.
It's still slower than RStudio, but I'm pretty sure RStudio has a wrapper around the R console and isn't sending text one line at a time.
@NeuKon If you want more speed when using the normal R console you can try adding this to settings.json:
"r.bracketedPaste": true
This option is designed for radian, but it might work for you in the normal R console too. If it produces odd formatting and strange extra characters around the code sent, please set it back to false.
Hi @andycraig, thank you for your help! I've been playing around with it over the last days. I ended up using the radian console and bracketed paste, resulting in a consistent speed similar to RStudio (on a Mac). Bracketed Paste - activated through the graphical VScode extensions settings - did not work consistently without Radian. In addition to adding extra characters it seemed to interfere with the Sessionwatcher. That is, plots did not open in VScode directly (which I did not mind) but I could not get auto completion for data.frames.
I would also consider this issue resolved now, even without radian and bracketed paste.
@NeuKon To my knowledge, session watcher has nothing to do with bracketed paste mode and radian console. They should work well together if properly configured.
Your observation that plots are not open and no completion for data frames must be caused by session watcher not properly initialized. You may need to take a look at https://github.com/Ikuyadeu/vscode-R/wiki/R-Session-watcher. If you have further questions, you may raise a new issue.
@renkun-ken I will have a look and may raise an issue there. I think it was related to how R sessions are initialized. It didn't work if I checked the box to only use the active terminals and initialised sessions manually.
I specified radian as my default R location in the extension settings and let the extension initialize session automatically. This is triggering a [1] FALSE each time a session is established but works fine otherwise.
EDIT: Your link clearly states that some extra configuration is needed for self-managed sessions. The sessionwatcher not working was almost certainly a mistake on my end.
@NeuKon For using session watcher with self-managed R sessions, You may take a look at my .Rprofile at https://github.com/renkun-ken/dotfiles/blob/master/.Rprofile#L27-L31.
The [1] FALSE issue is already fixed by #303 but it's not released yet.
Most helpful comment
@renkun-ken I've noticed this as well. Thank you for identifying it as being related to bracketed paste mode. I want to do a PR this week for #117 which will send code as one string instead of line by line when using bracketed paste mode. Hopefully that will take care of this problem as well.