Open Yunuuuu opened 2 years ago
I tried sending your code to R without bracket paste mode and sending it to radian with bracket paste mode. Both work as expected.
Thanks for your quickly reply, I came across it one time in every two times run of this code:
probe_with_one_more_gene <- Other$UCSC_RefGene_Name %>%
purrr::map(~ unique(str_split(., pattern = ";")[[1]])) %>%
purrr::map_lgl(
~ length(.) >= 2
) %>%
{ # nolint
rownames(Other)[.]
}
I don't know what's the matter, it agains
Do you select the code and send it or put the cursor in the beginning of the code and send it?
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 + ENTER
What if you remove # nolint
and try again?
Thanks for your help, it remains here
and I can delete code after character +
.
I move the curly braces to the last line or remove it, it remains here:
Looks like it is a Windows-specific issue where radian vscode 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?
What if you select the code and send it?
It remains here and I can delete code after character +
here is my .radian_profile:
# Do not copy the whole configuration, just specify what you need!
# see https://help.farbox.com/pygments.html
# for a list of supported color schemes, default scheme is "native"
options(radian.color_scheme = "monokai")
# either `"emacs"` (default) or `"vi"`.
# options(radian.editing_mode = "emacs")
# indent continuation lines
# turn this off if you want to copy code without the extra indentation;
# but it leads to less elegent layout
options(radian.indent_lines = FALSE)
# auto match brackets and quotes
options(radian.auto_match = FALSE)
# highlight matching bracket
options(radian.highlight_matching_bracket = FALSE)
# auto indentation for new line and curly braces
options(radian.auto_indentation = TRUE)
options(radian.tab_size = 4)
# pop up completion while typing
options(radian.complete_while_typing = TRUE)
# the minimum length of prefix to trigger auto completions
options(radian.completion_prefix_length = 1)
# timeout in seconds to cancel completion if it takes too long
# set it to 0 to disable it
options(radian.completion_timeout = 0.05)
# add spaces around equals in function argument completion
options(radian.completion_adding_spaces_around_equals = TRUE)
# automatically adjust R buffer size based on terminal width
options(radian.auto_width = TRUE)
# insert new line between prompts
options(radian.insert_new_line = TRUE)
# the filename that local history is stored, this file would be used instead of
# `radian.global_history_file` if it exists in the current working directory
options(radian.local_history_file = ".radian_history")
# allows user defined shortcuts, these keys should be escaped when send through the terminal.
# In the following example, `esc` + `-` sends `<-` and `esc` + `m` sends `%>%`.
# Note that in some terminals, you could mark `alt` as `escape` so you could use `alt` + `-` instead.
options(radian.escape_key_map = list(
list(key = "-", value = " <- "),
list(key = "m", value = " %>% ")
))
I have tried to use windows terminal:wt
which support bracket paste mode
, although it need open another window, it may remain convenient with windows terminal:wt
quake mode. However, vscode can only send code to the vscode integrated terminal
instead of a outer terminal . I can config windows terminal:wt
by this setting
:
"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\\yunyu\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe",
"r.rterm.option": [
"-w",
"_quake",
"new-tab",
"C:\\Users\\yunyu\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\radian.exe",
"--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"
}
Normally, hitting enter
on 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.
@Yunuuuu What happens if you just copy and paste the code to the radian console on vscode terminal?
Hi randy3k, thanks for your help, but it should run code when I using Ctrl + ENTER
to send code to terminal, shouldn't it?
When I paste the code to it, like this:
Both are the results of copy and paste the code? Or just the bottom?
I was asking that to determine if it was an issue introduced by vscode or an issue of radian itself.
Both are pasted into the terminal.
I have tested by coping this code and pasting it multiple times.
if the first pasting comes with a character +
, the code after that is always no problem.
if the first pasting comes without
a character +
, the code (two or more) after that will enter a error eventually.
I have tested by coping this code and pasting it multiple times.
Thanks. But it's expected to fail if you just copy and paste multiple times without executing the code.
Though the + sign is concerning, I don't expect to see it when copy and paste.
randy3k, Could it be resolved in windows? I have switched to rterm.exe, but it’s really defective without some elementary features.
Could you reproduce the copy and paste issue in an external terminal outside of vscode? Say powershell or Microsoft Terminal?
they all just correct without any error when implementing the pasting in powershell, cmd.exe, or Microsoft Terminal
I have tried to create radian in vscode using powershell shell, which gave a same problem
So this is the problem of vscode?
I, sometimes, encounter this as well. It's pretty random.
Have to type Enter
again in Radian to run the codes that have been sent to run.
Hi everyone. I think I encountered the same problem a while ago and I believe adding options(radian.auto_match = FALSE)
to my .Rprofile
fixed it for me.
Thanks for telling me that. I have turned radian.auto_match
option to FALSE
, but it didn't help.
I just realize that it could be a trailing new line issue: see this for discussion.
Could it be fixed? I have tried code with trailing space or without, all of them behave alike. Or can we always send a ENTER
operation when sending code in windows? A ENTER
operation won't break any code, will it?
I don't know whether vscode-r or radian could provide such operation ? the pause after sending code is annoying, which we must run code manually.
Hi, I have found a way to do this. We should install another extension(multi-command) to run multiply command with just a keybinding at once. Just create a new keybinding:
// send code for R
{
"key": "ctrl+enter",
"command": "extension.multiCommand.execute",
"when": "editorLangId == r || editorLangId == rmd && editorTextFocus",
"args": {
"sequence": [
"r.runSelection",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'r'"
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'rmd'"
}
It remains here, the code sometimes don't run.
radian sometimes cannot explain workbench.action.terminal.sendSequence \u000D
command like this.
The code didn't run but inserted a new line character.
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.runSelection
in windows since the ENTER
code (like \u000D
or \u000A
) send from vscode is just explained by radian as next 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.
I'm not sure whether the vscode command workbench.action.terminal.sendSequence
with a argument "\u000D" is just like we type ENTER
in terminal directly? If this is true, it indicatesradian
cannot deal with ENTER
type correctly in windows? I don't know how to test these.
As far as I know, from radian's perspective, sending \u000D
is the correct way to send "Enter" to radian.
I just realized I have never asked, what version of radian are you using?
radian version: 0.5.12
python version: 3.9.7
I have updated to the latest version (0.5.13), the problem remains here.
It seems following operation would just be explained as Next Line
when we send this command with r.runSelection
simultaneously and meanwhile the code implemented by r.runSelection
don't run effectively:
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
I finally found a nice way to use vscode-r
with radian
in windows. I Just post it here in case some windows users may have been confused of the conjunction of the both (vscode-r
and radian
).
Problem 1: there will be exceeding brackets
occasionally when we sending code to the terminal.
Solution 1: turn off the option radian.auto_match
of radian
in the .radian_profile
Problem 2: The code sending to radian
terminal from the editor by inputting ENTER
+ CTRL
will not be run, which we need implement it manually in the terminal panel by inputting ENTER
.
Solution 2: Firstly, we should install another extension (multi-command), then, override the ENTER
+ CTRL
keyboard with following keybindings setting in vscode
:
// send code for R
{
"key": "ctrl+enter",
"command": "extension.multiCommand.execute",
"when": "editorLangId == r || editorLangId == rmd && editorTextFocus",
"args": {
"interval": 20, // this is needed to execute following both command asynchronousely, otherwise, the problem would remain here
"sequence": [
"r.runSelection",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'r'"
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'rmd'"
}
Finally, we need turn off the option r.bracketedPaste
of vscode-r
, which is opposite to what is suggested in the vscode-r
manual. I have tried several times which confirmed that above setting would only work by turning off this option.
Finally, we need turn off the option
r.bracketedPaste
ofvscode-r
, which is opposite to what is suggested in thevscode-r
manual. I have tried several times which confirmed that above setting would only work by turning off this option.
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.
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.
// send code for R from https://github.com/REditorSupport/vscode-R/issues/820
{
"key": "ctrl+enter",
"command": "extension.multiCommand.execute",
"when": "editorLangId == r || editorLangId == rmd && editorTextFocus",
"args": {
"interval": 20, // this is needed to execute following both command asynchronousely, otherwise, the problem would remain here
"sequence": [
"r.runSelection",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
},
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'r'"
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId == 'rmd'"
}
I'm still having this issue, even after trying the radian.auto_match
fix. 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.
I have a similar problem, after attempting the solution here
My command is long - could be why
urban_rural <- read_sf("data/boundaries/statsnzstatistical-area-1-higher-geographies-2018-generalised-SHP/statistical-area-1-higher-geographies-2018-generalised.shp")
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
//FIX FOR RADIAN ISSUE from https://github.com/REditorSupport/vscode-R/issues/820
{
"key": "ctrl+enter",
"command": "extension.multiCommand.execute",
"when": "editorTextFocus && editorLangId =~ r|rmd/",
"args": {
"interval": 20, // this is needed to execute following both command asynchronousely, otherwise, the problem would remain here
"sequence": [
"r.runSelection",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}//,
// {
// "command": "workbench.action.terminal.sendSequence",
// "args": { "text": "\u000D" }
// }
]
}
},
{
"key": "ctrl+enter",
"command": "extension.multiCommand.execute",
"when": "(editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'quarto')||activeCustomEditorId == 'quarto.visualEditor'",
"args": {
"interval": 20, // this is needed to execute following both command asynchronousely, otherwise, the problem would remain here
"sequence": [
"quarto.runCurrent",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+shift+enter",
"command": "extension.multiCommand.execute",
"when": "(editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'quarto')||activeCustomEditorId == 'quarto.visualEditor'",
"args": {
"interval": 20,
"sequence": [
"quarto.runCurrentCell",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "alt+enter",
"command": "extension.multiCommand.execute",
"when": "(editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'quarto')||activeCustomEditorId == 'quarto.visualEditor'",
"args": {
"interval": 20,
"sequence": [
"quarto.runSelection",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+alt+p",
"command": "extension.multiCommand.execute",
"when": "(editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'quarto')||activeCustomEditorId == 'quarto.visualEditor'",
"args": {
"interval": 20,
"sequence": [
"quarto.runPreviousCell",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+alt+n",
"command": "extension.multiCommand.execute",
"when": "(editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'quarto')||activeCustomEditorId == 'quarto.visualEditor'",
"args": {
"interval": 20,
"sequence": [
"quarto.runNextCell",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+alt+r",
"command": "extension.multiCommand.execute",
"when": "(editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'quarto')||activeCustomEditorId == 'quarto.visualEditor'",
"args": {
"interval": 20,
"sequence": [
"quarto.runAllCells",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u000D" }
}
]
}
},
{
"key": "ctrl+enter",
"command": "-r.runSelection",
"when": "editorTextFocus && editorLangId =~ r|rmd/"
}
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 inputENTER
manually to run the code.To Reproduce Steps to reproduce the behavior:
library(tidyverse)
probe_with_one_more_gene <- Other$UCSC_RefGene_Name %>% purrr::map(~ unique(str_split(., pattern = ";")[[1]])) %>% purrr::map_lgl( ~ length(.) >= 2 ) %>% { # nolint rownames(Other)[.] }
Expected behavior Run code directly when sending code by typing
Ctrl + ENTER
Environment (please complete the following information):
Additional context If we could run code line by line like
raw r terminal
when sending code?