question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run Selection/Line fails when some lines end in commas

See original GitHub issue

Describe the bug

Lines ending in commas seem to cause R: Run Selection/Line to send the wrong lines to the console.

To Reproduce

  1. Create a file temp.R with the following content:
list(
    1,
    2
)
  1. Place cursor on second or third line
  2. Use command R: Run Selection/Line

Expected: All four lines are sent to console (if cursor was on second line), or only ‘2’ is sent to console (if cursor was on third line)

Actual: Middle two lines are sent to console:

> 1,
Error: unexpected ',' in "1,"
>     2
[1] 2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
andycraigcommented, Nov 5, 2022

Would anyone like to volunteer to try making the one-line change I suggested above? I think that would probably fix the comma issue and also change the behaviour so that parenthesised expressions split over several lines are sent to the console in full. If that works, a few unit tests would also need to be updated and then a PR could be made.

If no volunteers I will probably make the change myself at some point but hard to say when.

1reaction
brianmsmcommented, Aug 11, 2022

I don’t quite understand why this is the expected behavior. Everything inside a parenthesis, are there because their working together makes it work… in addition to the parenthesis itself. It’s a similar issue to whether or not line execution should involve pipe. It doesn’t make sense to execute without pipe, and it doesn’t make sense to execute an individual line inside a parenthesis without the function that calls it.

In the example of:

a(
    b(
        1
    )
)

Yes, all 5 lines should be executed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run Selection/Line fails when some lines end in commas #437
The problem is that the algorithm treats commas the same as operators like '+', so it views lines 2 and 3 as a...
Read more >
Why do lots of programmers move commas to the next line?
In SQL, trailing commas will cause syntax errors. In JavaScript, it will be accepted most places, but will fail with a cryptic error...
Read more >
Run-On Sentences and Sentence Fragments - Grammar
One common type of run-on sentence is a comma splice. A comma splice occurs when two independent clauses are joined with just a...
Read more >
Leading with commas — ugly or efficient? An investigation ...
Most projects (at least 69,665 repos) show only trailing commas at the end of SQL lines. 571 repos show only leading commas, and...
Read more >
SFTP Syncs: Troubleshooting CSV formatting errors
Error codes 3. Trailing commas 4. Extra commas in field values 5. ... file as a CSV file can create extra commas at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found