Bug with Code Execution by Ctrl-Enter in Windows

rstudio

#1

There is a bug with code execution when pressing Ctrl-Enter in Windows (and I'm guessing it is general to all of Rstudio).

Can you please update the code parsing so that it will look to the previous line to see if the current line is a continuation?

With the following code:

foo1(
  a=1,
  b=1) %>%
  foo2(a=foo3(
    b=bar))

If I press Ctrl-Enter on the first line (with foo1), it executes the entire block correctly (giving an error that it can't find foo1):

> foo1(
+   a=1,
+   b=1) %>%
+   foo2(a=foo3(
+     b=bar))
Error in foo1(a = 1, b = 1) : could not find function "foo1"

If I press Ctrl-Enter on the last line (with b=bar), it does not accurately look back all the way to the foo1 line, it just looks back to the foo2 line:

>   foo2(a=foo3(
+     b=bar))
Error in foo2(a = foo3(b = bar)) : could not find function "foo2"

#2

I'm seeing something slightly different -- it looks more like the first line is missed for some reason.

>   a=1,
Error: unexpected ',' in "  a=1,"
>   b=1) %>%
Error: unexpected ')' in "  b=1)"
>   foo2(a=foo3(
+     b=bar))
Error in foo2(a = foo3(b = bar)) : could not find function "foo2"
> 

Does that match what you see?


#3

In case it matters, I'm using version 1.1.423.

You're right-- I was just looking at the last error. The issue remains that it's not looking far enough back.


#4

Yes indeed, I just wanted to make sure we were seeing the exact same behavior. I've now filed this on our issue tracker at https://github.com/rstudio/rstudio/issues/3003. Thanks for reporting!