REditorSupport / REditorSupport/vscode-R

Unexpected Closing Parentheses and Braces When Executing Code Chunks in R

Open
#1,390 10 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
1.2k
Forks
139
Avg merge
2h 46m
Merged PRs (30d)
5

Description

Describe the bug
When executing certain chunks of R code using VSCode with the R extension and Radian, I sometimes observe additional closing parentheses or braces being sent to the console, which were not present in the original code. This issue seems to occur after a small delay.

To Reproduce
This issue occurs sporadically and I have been unable to identify a consistent pattern. However, I've noticed that it happens frequently when I run the following chunks of R code multiple times:

data_test <- reduce(rep(list(mtcars), 2), bind_rows)

Can you fix this issue by yourself? (We appreciate the help)

No

(If applicable) Please attach setting.json

{
    "[r]": {
        "editor.defaultFormatter": "REditorSupport.r",
        "editor.formatOnSave": false,
        "editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?"
    },
    "[rmd]": {
        "editor.defaultFormatter": "REditorSupport.r",
        "editor.formatOnSave": false
    },
    "r.rmarkdown.knit.openOutputFile": true,
    "r.rmarkdown.codeLensCommands": [
        "r.runCurrentChunk",
        "r.runAboveChunks",
        "r.runBelowChunks"
    ],
    "r.source.encoding": "UTF-8",
    "r.source.focus": "editor",
    "r.alwaysUseActiveTerminal": false,
    "r.sessionWatcher": true,
    "r.rtermSendDelay": 8,
    "r.plot.useHttpgd": true,
    "r.lsp.debug": true,
    "r.rterm.windows": "C:\\Users\\brian\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\radian.exe",
    "r.liveShare.defaults.commandForward": true,
    "r.rterm.linux": "/usr/bin/radian",
    "r.liveShare.defaults.shareBrowser": true,
    "r.bracketedPaste": true,
    "r.session.levelOfObjectDetail": "Normal"
}

Expected behavior
I expect the code to be sent to the console as it is, without any additional characters.

Screenshots
Animation

Environment (please complete the following information):

  • OS: Windows 11
  • R Version: 4.3.0
  • VSCode Version: 1.79.2
  • Radian Version: 0.6.4

Additional context
I noticed that when I format the code differently, the problem does not occur. For instance, the following code does not produce the issue:

data_test <- reduce(
  rep(list(mtcars), 2),
  bind_rows
)

In addition, it also does not play when instead of using bind_rows, I use rbind :

data_test <- reduce(rep(list(mtcars), 2), rbind)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in VS Code with the R extension and Radian using the provided reduce/rep/bind_rows chunk, Windows environment, and settings. Compare repeated execution with the reformatted and rbind examples; done means the original chunk is sent without extra closing parentheses or braces.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.