pimentel / atom-r-exec

Send R code to various R consoles from the Atom editor
https://atom.io/packages/r-exec
MIT License
19 stars 8 forks source link

Cannot send a large chunk of R code to iTerm2 on Mac OS X #44

Closed mattocci27 closed 6 years ago

mattocci27 commented 7 years ago

If I send (cmd-enter) a large chunk of R code to iTerm2, iTerm2 does not recognize the original code.

For example, R is supposed to recognize test as a function (although the function itself is meaningless),

test <- function(){
  rnorm(100)
  rnorm(100)
  rnorm(100)
# ...(please repeat these 100 times)...#
  rnorm(100)
  rnorm(100)
}

but this will return something like below.

+   rnorm(100)
+   rnorm(100)
+   rnorm(100)
+   rnorm(100)
+   rnorm(100)
+   r  r  r  r  r  r  r10  r  r  r  10  r  r  r  10  r  r  r  10  r  r  r  10  r  rnorm(100)
Error: unexpected symbol in:
"  rnorm(100)
  r  r"
>   rnorm(10  rnorm(10(100)
Error: unexpected symbol in "  rnorm(10  rnorm"
>   rnorm(10  rnorm(10 10  rnorm(10 10  rnorm(10 10  rnorm(1m(10  rnorm(10(10  rnorm(rm(100)
Error: unexpected symbol in "  rnorm(10  rnorm"

It does not happen when I use R.app or Terminal. I'm not sure if it's just me or bug of iTerm2 or r-exec. Thanks.

Atom: 1.12.9
r-exec: 0.4.1
iTerm2: Build 3.0.13
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.2
pimentel commented 7 years ago

Thanks for reporting. I have verified this bug. Very strange stuff... I suspect there is an issue with the iTerm2 applescript implementation. I'm going to see if there is a workaround and will probably end up reporting something to the iTerm people.

pimentel commented 7 years ago

Hm. It looks like there is some specific issue with the command line R, not iTerm or r-exec. For example, the sequencing of everything turns out correct when you send it to an open buffer of nano rather than R.

it's kind of annoying, but I guess I will have to figure out what the maximum buffer size for R in the terminal app is and break it into different chunks.

guillaumechaumet commented 7 years ago

When I copy paste a large chunk in slowly mode of iterm2, there is no issue. edit: I find this post and the clipboard section of ?file:

macOS users can use ‘pipe("pbpaste")’ and ‘pipe("pbcopy", "w")’ to read from and write to that system's clipboard.

mattocci27 commented 6 years ago

This issue seems to be fixed in macOS 10.13 (high sierra).

jdyeakel commented 6 years ago

I'm having the same issue with iTerm Build 3.1.4.beta.1 from Atom 1.21.1, running Mac OS 10.13. Works fine when I copy and paste large chunks of R (v 3.4.2) code into Terminal, and works if I break up the code into smaller copy-pasted chunks... otherwise it breaks. This only appears to be a problem with running R in iTerm (e.g. no problems doing the same thing with Julia).

zpamaral commented 5 years ago

Was a workaround for this issue ever found? I am running iTerm2 3.2.1beta5 and R version 3.5.1 on macOS High Sierra 10.13.6 and I see the same problem. I have an AppleScript script to send highlighted R code from BBEdit to R running on a terminal session, and it fails send multiple-line selections. However, if I select just a few lines of code, then it will work.