diff --git a/R/reprex.R b/R/reprex.R index 7a24a11a..2df525d3 100644 --- a/R/reprex.R +++ b/R/reprex.R @@ -374,7 +374,7 @@ reprex <- function(x = NULL, " * ", reprex_file ) if (yep("Open the output file for manual copy?")) { - withr::defer(utils::file.edit(reprex_file)) + withr::defer(file_edit(reprex_file)) } } diff --git a/R/utils.R b/R/utils.R index ee580b8b..e6ea27a0 100644 --- a/R/utils.R +++ b/R/utils.R @@ -97,3 +97,11 @@ collapse <- function(x, sep = "\n") { backtick <- function(x) encodeString(x, quote = "`") newline <- function(x) paste0(x, "\n") + +file_edit <- function(...) { + if (exists("file.edit", envir = globalenv())) { + get("file.edit", envir = globalenv())(...) + } else { + utils::file.edit(...) + } +}