Skip to content

Commit

Permalink
use new rstudioapi shim for reindent in Positron (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored Oct 25, 2024
1 parent f2f388b commit cc7f007
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
9 changes: 1 addition & 8 deletions R/rstudioapi.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,7 @@ stream_selection <- function(selection, context, pal, n_lines_orig) {

# reindent the code
rstudioapi::setSelectionRanges(selection$range, id = context$id)
if (is_positron()) {
# TODO: this is not public api. we actually want to make a PR to
# positron to map reindent -> this_command in the rstudioapi shims (#46)
.ps.ui.executeCommand("editor.action.reindentselectedlines")
} else {
rstudioapi::executeCommand("reindent")
}

rstudioapi::executeCommand("reindent")

rstudioapi::setCursorPosition(selection$range$start)
}
Expand Down
4 changes: 0 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,3 @@ interactive <- NULL
is_valid_role <- function(role) {
grepl("^[a-zA-Z0-9]+$", role)
}

is_positron <- function() {
Sys.getenv("POSITRON") == "1"
}

0 comments on commit cc7f007

Please sign in to comment.