diff --git a/R/reprex.R b/R/reprex.R index 3940df1f..6301254a 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_edit2(reprex_file)) } } diff --git a/R/utils.R b/R/utils.R index bbc4aa1a..5a7ced8b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -89,3 +89,15 @@ inject_file <- function(path, inject_path, pre_process = enfence, ...) { prose <- function(x) { paste0("#' ", x) } + +is_windows <- function() { + grepl("windows", Sys.info()[["sysname"]], ignore.case = TRUE) +} + +file_edit2 <- function(file) { + if (is_windows()) { + get("file.edit")(file) + } else { + utils::file.edit(file) + } +}