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.

Send code to terminal by `Ctrl + ENTER` but don't run

See original GitHub issue

Describe the bug When I send code to terminal by Ctrl + ENTER, it just send code but don’t run code, and we should move focus to terminal and input ENTER manually to run the code.

To Reproduce Steps to reproduce the behavior:

  1. create a terminal
  2. run this code below:
library(IlluminaHumanMethylation450kanno.ilmn12.hg19)  
## sorry for this, I have tried other code which don't rely on any package data to reproduce this problem but it failed.
## this package is from bioconductor
## so we should install it by  BiocManager::install("IlluminaHumanMethylation450kanno.ilmn12.hg19")

library(tidyverse)

After loading packages, try this code below several times, the frequency of problem is almost 1/2, so it won’t be hard to reproduce this problems

probe_with_one_more_gene <- Other$UCSC_RefGene_Name %>%
  purrr::map(~ unique(str_split(., pattern = ";")[[1]])) %>%
  purrr::map_lgl(
    ~ length(.) >= 2
  ) %>%
  { # nolint
    rownames(Other)[.]
  }
  1. See error (it seems vscode-r just run code before line rownames(Other)[.] and after code wasn’t run, as we could see a character + after the line rownames(Other)[.] which indicates the line before should have been run.) image

if we don’t run it manully, we can even delete code like this. image

The problems only occured in radian terminal no matter I turn on or off r.bracketedPaste setting. the code run by raw r terminal is like this which looks like raw r terminal run code line by line as indicated by the character +. image

Do you want to fix by self? (We hope your help!)

Yes, I want to be helpful.

(If yes,) what kind of help do you want? (e.g. Which file should I fix, Survey (related documents)

(If related)setting.json

    "[r]": {
        "editor.rulers": [
            80 
        ],
        "editor.wordWrap": "bounded",
        "editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?",
        "rewrap.autoWrap.enabled": true,
        "rewrap.wrappingColumn": 80,
        "rewrap.doubleSentenceSpacing": true
    },
    "r.alwaysUseActiveTerminal": true,
    // "r.bracketedPaste": true,
    "r.rpath.windows": "C:\\Yun\\R\\R-4.1.1\\bin\\x64\\R.exe",
    "r.rterm.windows": "C:\\Users\\****\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\radian.exe",
    // "r.rterm.windows": "C:\\Yun\\R\\R-4.1.1\\bin\\x64\\Rterm.exe",
    "r.rterm.option": [
        "--no-save",
        "--no-restore",
        "--local-history",
        "--r-binary=C:\\Yun\\R\\R-4.1.1\\bin\\x64\\R.exe"
    ],
    "r.plot.useHttpgd": true,
    "r.session.levelOfObjectDetail": "Detailed",
    "r.session.objectLengthLimit": 100,
    "r.session.viewers.viewColumn": {
        "plot": "Active",
        "viewer": "Active",
        "view": "Active",
        "helpPanel": "Active"
    }

Expected behavior Run code directly when sending code by typing Ctrl + ENTER

Environment (please complete the following information):

  • OS: Windows 19042.1237
  • VSCode Version: 1.61.0
  • R Version: 4.1.1
  • vscode-R version: v2.3.1

Additional context If we could run code line by line like raw r terminal when sending code?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:42 (39 by maintainers)

github_iconTop GitHub Comments

4reactions
Yunuuuucommented, Dec 30, 2021

I finally found a nice way to use vscode-r with radian in windows. I Just post it here in case some windows users may have been confused of the conjunction of the both (vscode-r and radian).

Problems and solutions are as follows:

The first one:

Problem 1: there will be exceeding brackets occasionally when we sending code to the terminal. Solution 1: turn off the option radian.auto_match of radian in the .radian_profile

The second one:

Problem 2: The code sending to radian terminal from the editor by inputting ENTER + CTRL will not be run, which we need implement it manually in the terminal panel by inputting ENTER. Solution 2: Firstly, we should install another extension (multi-command), then, override the ENTER + CTRL keyboard with following keybindings setting in vscode:

    // send code for R
    {
        "key": "ctrl+enter",
        "command": "extension.multiCommand.execute",
        "when": "editorLangId == r || editorLangId == rmd && editorTextFocus",
        "args": {
            "interval": 20, // this is needed to execute following both command asynchronousely, otherwise, the problem would remain here
            "sequence": [
                "r.runSelection", 
                {
                    "command": "workbench.action.terminal.sendSequence",
                    "args": { "text": "\u000D" }
                }
            ]
        }
    },
    {
        "key": "ctrl+enter",
        "command": "-r.runSelection",
        "when": "editorTextFocus && editorLangId == 'r'"
    },
    {
        "key": "ctrl+enter",
        "command": "-r.runSelection",
        "when": "editorTextFocus && editorLangId == 'rmd'"
    }

Finally, we need turn off the option r.bracketedPaste of vscode-r, which is opposite to what is suggested in the vscode-r manual. I have tried several times which confirmed that above setting would only work by turning off this option.

1reaction
toscmcommented, Oct 13, 2021

Hi everyone. I think I encountered the same problem a while ago and I believe adding options(radian.auto_match = FALSE) to my .Rprofile fixed it for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code: Shift+Enter does not send code to Python Interactive
Shift + Enter is registered as a keyboard shortcut for both sending code to Terminal and for sending it to Python Interactive. I...
Read more >
VS Code: How to Switch Between Code and Terminal ...
In VS Code CTRL + tilde sends you to the terminal, but CTRL + SHIFT + ` instead opens a new terminal session....
Read more >
enabling ctrl+enter to execute current line in .py script ... - GitHub
I'm finding that using ctrl+enter on a .py source file comment line still sends it to the terminal and doesn't complete line execution...
Read more >
Terminal | IntelliJ IDEA Documentation - JetBrains
Configure: Settings/Preferences Ctrl+Alt+S | Tools | Terminal ... Use it to run Java tools, Git commands, set file permissions, and perform ...
Read more >
Debugging in Visual Studio Code
Note: You can debug a simple application even if you don't have a folder open ... Finer breakpoint control (enable/disable/reapply) can be done...
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