Skip to content

Conversation

@cwickham
Copy link

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 on lines +456 to +459
output_context$nspc <- 4
if (rstudioapi::hasFun("readRStudioPreference")) {
rstudioapi::readRStudioPreference("num_spaces_for_tab", 4)
}
Copy link
Owner

@MilesMcBain MilesMcBain Nov 1, 2025

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
Copy link
Owner

MilesMcBain commented Nov 1, 2025

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