Run Selection/Line fails when some lines end in commas
See original GitHub issueDescribe the bug
Lines ending in commas seem to cause R: Run Selection/Line to send the wrong lines to the console.
To Reproduce
- Create a file
temp.Rwith the following content:
list(
1,
2
)
- Place cursor on second or third line
- 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:
- Created 3 years ago
- Reactions:1
- Comments:17 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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:
Yes, all 5 lines should be executed.