You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
528 B

#' Path Split
#'
#' @export
pathSplit <- function() {
ctx <- rstudioapi::getActiveDocumentContext()
print(str(ctx$selection))
if (!is.null(ctx)) {
if (ctx$selection[[1]]$text != "") {
found <- stri_match_first_regex(ctx$selection[[1]]$text, '"([^"]*)"')
repl <- paste0(sprintf('"%s"', unlist(fs::path_split(found[2]))), collapse = ", ")
rstudioapi::modifyRange(
ctx$selection[[1]]$range,
stri_replace_first_fixed(ctx$selection[[1]]$text, found[1], repl)
)
}
}
}