Skip to content

Enable Positron use#145

Open
cwickham wants to merge 3 commits into
MilesMcBain:masterfrom
cwickham:positron
Open

Enable Positron use#145
cwickham wants to merge 3 commits into
MilesMcBain:masterfrom
cwickham:positron

Conversation

@cwickham

Copy link
Copy Markdown

Check for rstudio::readRStudioPreference() before attempting to run it.

Allows tribble_paste() to work in Positron. Positron users will get 4 spaces for a tab with no consultation of their preferences.

Comment thread R/tribble_paste.R
Comment on lines +456 to +459
output_context$nspc <- 4
if (rstudioapi::hasFun("readRStudioPreference")) {
rstudioapi::readRStudioPreference("num_spaces_for_tab", 4)
}

@MilesMcBain MilesMcBain Nov 1, 2025

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was intended to be something like:

 output_context$nspc <-
  if (rstudioapi::hasFun("readRStudioPreference")) {
    rstudioapi::readRStudioPreference("num_spaces_for_tab", 4)
  } else {
    4
  }

@MilesMcBain

MilesMcBain commented Nov 1, 2025

Copy link
Copy Markdown
Owner

I am wondering why the Positron RStudioAPI emulation does not implement studioapi::readRStudioPreference as the R VSCode extension has done?

I only say this because the function has the default argument which is already in use here to return 4 where the preference cannot be found.

So VSCode-R does:

readRStudioPreference <- function(name, default) {
    ## in future we could map some rstudio preferences to vscode settings.
    ## since the caller must provide a default this should work.
    default
}

P.S.

Thanks for taking the time to make this PR! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants