Skip to content

Run Selection can't handle multi line strings #1313

Open

Description

@gowerc

Describe the bug

When trying to submit the following code snippet only the first line gets submitted (i.e. just the x <- "

x <- "
a
"

For reference Rstudio seems to submit the whole chunk

To Reproduce

  • Create a new file
  • Enter the above snippet
  • Place cursor infront of the x
  • try submitting via ctrl+enter

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

No (sorry)

Expected behavior
The whole string gets submitted

Environment (please complete the following information):

  • OS: macOS
  • VSCode Version: 1.75.1
  • R Version: 4.2.2
  • vscode-R version: v2.7.1

Activity

  1. github-actions commented on Mar 1, 2024

    @github-actions

    This issue is stale because it has been open for 365 days with no activity.

  2. gowerc commented on Mar 1, 2024

    @gowerc
    ContributorAuthor

    Not stale

  3. ml-crowe commented on May 16, 2024

    @ml-crowe

    I am running into this same issue.

  4. davidmasp commented on Jun 11, 2024

    @davidmasp

    me too

    R version 4.1.2
    R vs code v2.8.4
    vscode 1.90.0

  5. davidmasp commented on Jun 11, 2024

    @davidmasp

    Might be related to this? #731

    There they say that another R extension for VS code is messing up this behavior.

    I can confirm that when running with the command palette works fine but I don't have any other R extension mentioned in the other issue

  6. davidmasp commented on Jun 11, 2024

    @davidmasp

    okay so i figure it out, I had the same shortcut to send code to the terminal for all file types, basically I used it for bash, when resetting that shortcut it started to work again.

    The cmd+Enter shortcut is quite populated so it was a bit hard to find. You can also manually change the shortcut for @command:r.runSelection to anything w/o collisions. For completeness, I think my conflict was coming from @command:workbench.action.terminal.runSelectedText +when:terminalProcessSupported that I manually set some time ago.

  7. ThomasSoeiro commented on Sep 27, 2026

    @ThomasSoeiro
    Collaborator

    @eitsupi @Fred-Wu @grantmcdermott Is this something we can work around? Perhaps it can be added to a milestone? (I'm probably biased, since this bug keeps bothering me regularly…)

  8. eitsupi commented on Sep 27, 2026

    @eitsupi
    Member

    Incidentally, I believe arf console achieves this by using tree-shitter to determine if it's a complete R expression before executing it.
    I think the same thing could probably be done here, but I don't think I'll be doing the implementation myself, so contributions from anyone willing to do so are welcome.

  9. Fred-Wu commented on Sep 27, 2026

    @Fred-Wu
    Contributor

    One workaround is to use r"()", but can only submit as a whole at the closing quote.

    test <- r"(
     hello
    )"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions