Repository navigation
Send code to terminal by Ctrl + ENTER but don't run #820
Description
Describe the bug
When I send code to terminal by Ctrl + ENTER, it just send code but don't run code, and we should move focus to terminal and input ENTER manually to run the code.
To Reproduce
Steps to reproduce the behavior:
- create a terminal
- run this code below:
library(IlluminaHumanMethylation450kanno.ilmn12.hg19)
## sorry for this, I have tried other code which don't rely on any package data to reproduce this problem but it failed.
## this package is from bioconductor
## so we should install it by BiocManager::install("IlluminaHumanMethylation450kanno.ilmn12.hg19")
library(tidyverse)
After loading packages, try this code below several times, the frequency of problem is almost 1/2, so it won't be hard to reproduce this problems
probe_with_one_more_gene <- Other$UCSC_RefGene_Name %>%
purrr::map(~ unique(str_split(., pattern = ";")[[1]])) %>%
purrr::map_lgl(
~ length(.) >= 2
) %>%
{ # nolint
rownames(Other)[.]
}
- See error (it seems vscode-r just run code before line
rownames(Other)[.]and after code wasn't run, as we could see a character+after the linerownames(Other)[.]which indicates the line before should have been run.)

if we don't run it manully, we can even delete code like this.

The problems only occured in radian terminal no matter I turn on or off r.bracketedPaste setting. the code run by raw r terminal is like this which looks like raw r terminal run code line by line as indicated by the character +.

Do you want to fix by self? (We hope your help!)
Yes, I want to be helpful.
(If yes,) what kind of help do you want? (e.g. Which file should I fix, Survey (related documents)
(If related)setting.json
"[r]": {
"editor.rulers": [
80
],
"editor.wordWrap": "bounded",
"editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?",
"rewrap.autoWrap.enabled": true,
"rewrap.wrappingColumn": 80,
"rewrap.doubleSentenceSpacing": true
},
"r.alwaysUseActiveTerminal": true,
// "r.bracketedPaste": true,
"r.rpath.windows": "C:\\Yun\\R\\R-4.1.1\\bin\\x64\\R.exe",
"r.rterm.windows": "C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\radian.exe",
// "r.rterm.windows": "C:\\Yun\\R\\R-4.1.1\\bin\\x64\\Rterm.exe",
"r.rterm.option": [
"--no-save",
"--no-restore",
"--local-history",
"--r-binary=C:\\Yun\\R\\R-4.1.1\\bin\\x64\\R.exe"
],
"r.plot.useHttpgd": true,
"r.session.levelOfObjectDetail": "Detailed",
"r.session.objectLengthLimit": 100,
"r.session.viewers.viewColumn": {
"plot": "Active",
"viewer": "Active",
"view": "Active",
"helpPanel": "Active"
}Expected behavior
Run code directly when sending code by typing Ctrl + ENTER
Environment (please complete the following information):
- OS: Windows 19042.1237
- VSCode Version: 1.61.0
- R Version: 4.1.1
- vscode-R version: v2.3.1
Additional context
If we could run code line by line like raw r terminal when sending code?
Activity
renkun-ken commentedon Oct 12, 2021
I tried sending your code to R without bracket paste mode and sending it to radian with bracket paste mode. Both work as expected.
Yunuuuu commentedon Oct 12, 2021
Thanks for your quickly reply, I came across it one time in every two times run of this code:
I don't know what's the matter, it agains
renkun-ken commentedon Oct 12, 2021
Do you select the code and send it or put the cursor in the beginning of the code and send it?
Yunuuuu commentedon Oct 12, 2021
I just put the cursor in the beginning of the code sometimes in the median of the first line of the code block and type
Ctrl + ENTERrenkun-ken commentedon Oct 12, 2021
What if you remove
# nolintand try again?Yunuuuu commentedon Oct 12, 2021
Thanks for your help, it remains here
and I can delete code after character

+.Yunuuuu commentedon Oct 12, 2021
I move the curly braces to the last line or remove it, it remains here:
renkun-ken commentedon Oct 12, 2021
Looks like it is a Windows-specific issue where
radianvscode terminal does not support bracket paste mode (is it still true today?). It does not occur on macOS and Linux.@randy3k Maybe it is because radian does not handle such expressions well on Windows?
renkun-ken commentedon Oct 12, 2021
What if you select the code and send it?
Yunuuuu commentedon Oct 12, 2021
It remains here and I can delete code after character
+Yunuuuu commentedon Oct 12, 2021
here is my .radian_profile:
Yunuuuu commentedon Oct 12, 2021
I have tried to use
windows terminal:wtwhich supportbracket paste mode, although it need open another window, it may remain convenient withwindows terminal:wtquake mode. However, vscode can only send code to thevscode integrated terminalinstead of a outer terminal . I can configwindows terminal:wtby thissetting:randy3k commentedon Oct 12, 2021
Normally, hitting
enteron radian would execute the input unless there is a syntax error. If the input is incomplete, radian will insert a new line after the code instead.However, something unexpected occurred to @Yunuuuu. The
+prompt means that at some point radian thinks that the code is executable and passes the input to R, but it really is not. Hence, the+prompt is shown.I imagine it may be a synchronization issue when a lot of text is "streamed" to R at the same time.
randy3k commentedon Oct 12, 2021
@Yunuuuu
What happens if you just copy and paste the code to the radian console on vscode terminal?
20 remaining items
Yunuuuu commentedon Dec 29, 2021
Hi, @randy3k and @renkun-ken , can radian or vscode-r extension provide a command for running code and we can define it in cooperation with vscode-r's command
r.runSelectionin windows since theENTERcode (like\u000Dor\u000A) send from vscode is just explained by radian asnext line? If these, we can just define a specific keyboard instead moving the focus to the terminal and running the code manually.Several problems concerning these have been raised, this problem is common in windows.
Yunuuuu commentedon Dec 29, 2021
I'm not sure whether the vscode command
workbench.action.terminal.sendSequencewith a argument "\u000D" is just like we typeENTERin terminal directly? If this is true, it indicatesradiancannot deal withENTERtype correctly in windows? I don't know how to test these.randy3k commentedon Dec 29, 2021
As far as I know, from radian's perspective, sending
\u000Dis the correct way to send "Enter" to radian.I just realized I have never asked, what version of radian are you using?
Yunuuuu commentedon Dec 29, 2021
Yunuuuu commentedon Dec 29, 2021
I have updated to the latest version (0.5.13), the problem remains here.
Yunuuuu commentedon Dec 29, 2021
It seems following operation would just be explained as
Next Linewhen we send this command withr.runSelectionsimultaneously and meanwhile the code implemented byr.runSelectiondon't run effectively:Yunuuuu commentedon Dec 30, 2021
I finally found a nice way to use
vscode-rwithradianin windows. I Just post it here in case some windows users may have been confused of the conjunction of the both (vscode-randradian).Problems and solutions are as follows:
The first one:
Problem 1: there will be exceeding
bracketsoccasionally when we sending code to the terminal.Solution 1: turn off the option
radian.auto_matchofradianin the.radian_profileThe second one:
Problem 2: The code sending to
radianterminal from the editor by inputtingENTER+CTRLwill not be run, which we need implement it manually in the terminal panel by inputtingENTER.Solution 2: Firstly, we should install another extension (multi-command), then, override the
ENTER+CTRLkeyboard with following keybindings setting invscode:Finally, we need turn off the option
r.bracketedPasteofvscode-r, which is opposite to what is suggested in thevscode-rmanual. I have tried several times which confirmed that above setting would only work by turning off this option.D3SL commentedon Jul 18, 2022
I've been giving this a shot for a while and at least for me it doesn't seem to be a working fix. I don't seem to get the extraneous characters at the end of things anymore but large ctrl+enter blocks will still "break" part way through and turn into colorless unformatted input, and I still have to switch focus to the console and manually hit enter quite often.
JosephineRoper commentedon Feb 27, 2023
I was also still having this problem (as per @D3SL - no extra characters after that fix, but often the code won't be ENTER-ed). This is a bit of a kludgy fix, but I modified the keybinding above to include an extra enter. This means about half the time, a superfluous enter is sent and I get a blank line in the terminal after my output, but for me that's ok, much better than the previous situation.
JGBSilva commentedon May 18, 2023
I'm still having this issue, even after trying the
radian.auto_matchfix. My issue at the moment is not even it adding it in the end of the block of code in the terminal. Now it seems to add random } in the middle of the code, causing it to break and spitting errrs like: "Error: unexpected '}' in "}"", but at least it seems to auto-run the code when using Ctrl+Enter.Looking at the code inputed in the terminal, it seems the code block is being split at some random point and that causes the error. As you can see in this picture, the code was running and then it stopped, gave the error, and continued in a new command input.
kendonB commentedon Aug 23, 2023
I have a similar problem, after attempting the solution here
My command is long - could be why
MEpiVet commentedon Jun 18, 2024
Just adding the quarto keybindings to the above solutions; I personally didnt need the double enter. But did need the .radian_profile fix and no bracketed paste in settings
ThomasSoeiro commentedon Sep 26, 2026
Can you reproduce with vscode-r 3.0.0-rc.0 and Arf? Note that radian is no longer under active development.
Related to #1390 and #1090?
@eitsupi @Fred-Wu @grantmcdermott Close as obsolete?
eitsupi commentedon Sep 26, 2026
This is outdated, so I'm closing it.
Please let me know if you continue to experience problems.