Skip to content

vscode-r ignore r.session.viewers.viewColumn plot when using httpgd device for ploting #814

@Yunuuuu

Description

@Yunuuuu

Describe the bug
vscode-r ignore r.session.viewers.viewColumn plot when using httpgd device for ploting.

To Reproduce

  1. turn r.plot.useHttpgd to true,
  2. turn argument plot in r.session.viewers.viewColumn to "Active". the settings.json should like this
  "r.plot.useHttpgd": true,
  "r.session.viewers.viewColumn": {
        "plot": "Active"
    }
  1. run hist(1:100) in R terminal

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

Yes. I have tried this code in .Rprofile, it could work. but this may skip the raw plot viewer and use the vscode browser viewer? I don't know it clearly.

if (interactive() &&
    identical(Sys.getenv("TERM_PROGRAM"), "vscode") &&
    identical(getOption("vsc.use_httpgd", FALSE), TRUE)) {
    if ("httpgd" %in% .packages(all.available = TRUE)) {
        options(device = function(...) {
            httpgd::hgd(silent = TRUE)
            .vsc.browser(
                httpgd::hgd_url(),
                viewer = if (isFALSE(getOption("vsc.plot", "Two"))) {
                    "Two"
                } else {
                    getOption("vsc.plot", "Two")
                }
            )
        })
    } else {
        message("Install package `httpgd` to use vscode-R with httpgd!")
    }
}

my setting.json related to vscode-R

   "[r]": {
        "editor.rulers": [
            80 //,
            //{
            //    "column": 100,
            //    "color": "#00cbfd"
            //},
        ],
        "editor.wordWrap": "bounded",
        "editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?",
        "rewrap.autoWrap.enabled": true,
        "rewrap.wrappingColumn": 80,
        "rewrap.doubleSentenceSpacing": true
    },
    "r.lsp.debug": 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.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
plot viewer opened in the active editor.

Environment (please complete the following information):

  • OS: [e.g. Windows
  • VSCode Version: 1.61.0
  • R Version: 4.1.1
  • vscode-R version: v2.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions