randy3k / radian

A 21 century R console
MIT License
2k stars 76 forks source link

execute multiline selection in active [radian] terminal fails in vscode #320

Open mkarikom opened 2 years ago

mkarikom commented 2 years ago

environment:

R 4.1.1 (linux) vscode 1.62.1 vscode settings:

// Use active terminal for all commands, rather than creating a new R terminal.
"r.alwaysUseActiveTerminal": false,

not working:

Selecting the following and hitting <ctrl+enter> tries to execute but fails with error:

library("pasilla")
pasCts <- system.file("extdata",
                      "pasilla_gene_counts.tsv",
                      package="pasilla", mustWork=TRUE)

output:

r$> dds <- DESeqDataSetFromMatrix(countData = cts,)
Error in h(simpleError(msg, call)) :
  error in evaluating the argument 'x' in selecting a method for function 'nrow': argument "colData" is missing, with no default

r$>                               colData = coldata,
Error: unexpected ',' in "                              colData = coldata,"

r$>                               design = ~ condition)
Error: unexpected ')' in "                              design = ~ condition)"

working:

after reformatting the statement as a single line, it succeeds (using same keystrokes as above):

pasCts <- system.file("extdata","pasilla_gene_counts.tsv",package="pasilla", mustWork=TRUE)
file.exists(pasCts)

output:

r$> file.exists(pasCts)                                                                                                                                                                                                                                                                                         
[1] TRUE
randy3k commented 2 years ago

It seems to be a vscode specific issue.

yanhao-wang commented 2 years ago

Same here. Has this issue been solved? Thanks!

yanhao-wang commented 2 years ago

Or does anybody know any turnaround?

mkhq commented 2 years ago

@yanhao-wang Try to enable "R: Bracketed Paste"-mode in settings.

dereckmezquita commented 2 years ago

@yanhao-wang Try to enable "R: Bracketed Paste"-mode in settings.

This fixed it for me, thank you.

mmyrte commented 1 year ago

Ok, just trying to drop more keywords in this issue thread so that I and others might find it faster next time: we were wondering whether this was due to CRLF or LF line endings on a WSL2/devcontainer setup running an Ubuntu as guest. We then set up a pure Ubuntu machine and the issue persisted with CR apparently being inserted after every line. We could not reproduce the issue on vanilla R, so it seems specific to radian.

I suggest this issue be closed 🙂

randy3k commented 1 year ago

Long story short, it is not due to the newline char. It is due to the fact that Microsoft terminal didn't support bracketed paste mode. PS: Not sure the current status.

promicrobial commented 1 year ago

I'm having this same issue except with sublime text and sending code to terminus. It works fine when I use R without radian. Does anyone have any ideas how to solve this?

MichaelSchatz commented 12 months ago

I am having a similar issue only with going from RStudio to a terminal with Radian. Would love for there to be a solution for it. I really love using radian for all of its other features, but this becomes a workflow killer at times.

promicrobial commented 8 months ago

I'm having this same issue except with sublime text and sending code to terminus. It works fine when I use R without radian. Does anyone have any ideas how to solve this?

Based on a comment by @mkhq above https://github.com/randy3k/radian/issues/320#issuecomment-1125059020, I was able to solve the issue in Sublime Text by changing the SendCode settings file (Preferences -> .Package Settings -> SendCode -> Settings)

In the default settings file:

"r" : {
        "prog": "tmux",
        // turn bracketed_paste_mode on if radian or readline 7.0 is in use
        "bracketed_paste_mode": false 
    }

Changed to:

"r":
    {
        "bracketed_paste_mode": true,
        "prog": "terminus",
    }