diff --git a/DESCRIPTION b/DESCRIPTION index 0f9fbdd6..fa203067 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: orderly2 Title: Orderly Next Generation -Version: 1.99.10 +Version: 1.99.11 Authors@R: c(person("Rich", "FitzJohn", role = c("aut", "cre"), email = "rich.fitzjohn@gmail.com"), person("Robert", "Ashton", role = "aut"), diff --git a/R/interactive.R b/R/interactive.R index 98d9ea30..57d78c3f 100644 --- a/R/interactive.R +++ b/R/interactive.R @@ -21,13 +21,15 @@ rstudio_get_current_active_editor_path <- function() { ## ## I am not sure if we also want to allow working interactively from a ## draft directory too. -detect_orderly_interactive_path <- function(path = getwd(), - editor_path = rstudio_get_current_active_editor_path()) { +detect_orderly_interactive_path <- function( + path = getwd(), + editor_path = rstudio_get_current_active_editor_path()) +{ is_valid <- is_plausible_orderly_report(path) suggested_wd <- NULL if (!is.null(editor_path)) { dir <- fs::path_dir(editor_path) - if (paths_are_different(dir, path) && is_plausible_orderly_report(dir)) { + if (!paths_are_identical(dir, path) && is_plausible_orderly_report(dir)) { suggested_wd <- dir } } @@ -35,8 +37,9 @@ detect_orderly_interactive_path <- function(path = getwd(), if (!is_plausible_orderly_report(path)) { msg <- c("Working directory {.path {path}} is not a valid orderly report.") if (!is.null(suggested_wd)) { - cli::cli_abort( - c(msg, i = "Use {.code setwd({.str {suggested_wd}})} to set the working directory to the report currently open in RStudio.")) + cli::cli_abort(c(msg, i = paste( + "Use {.code setwd({.str {suggested_wd}})} to set the working", + "directory to the report currently open in RStudio."))) } else { cli::cli_abort(msg) } @@ -47,8 +50,12 @@ detect_orderly_interactive_path <- function(path = getwd(), # doesn't make individual bullet points available in the condition object. # The following mimicks cli_abort more closely, making testing easier. msg <- c( - cli::format_inline("Working directory {.path {path}} does not match the report currently open in RStudio."), - cli::format_inline(i = "Use {.code setwd({.str {suggested_wd}})} to switch working directories.")) + cli::format_inline(paste( + "Working directory {.path {path}} does not match the report currently", + "open in RStudio.")), + cli::format_inline(i = paste( + "Use {.code setwd({.str {suggested_wd}})}", + "to switch working directories."))) rlang::warn(msg, use_cli_format = TRUE) } as.character(fs::path_norm(file.path(path, "../.."))) diff --git a/R/util.R b/R/util.R index e5b41785..7b9640fc 100644 --- a/R/util.R +++ b/R/util.R @@ -634,12 +634,8 @@ saverds_atomic <- function(data, path, allow_fail = FALSE) { } -paths_are_different <- function(x, y) { - tryCatch({ - x_real <- fs::path_real(x) - y_real <- fs::path_real(y) - x_real != y_real - }, error = function(e) FALSE) +paths_are_identical <- function(x, y) { + fs::path_norm(x) == fs::path_norm(y) } diff --git a/tests/testthat/helper-orderly.R b/tests/testthat/helper-orderly.R index 48cd9f84..9ce5646d 100644 --- a/tests/testthat/helper-orderly.R +++ b/tests/testthat/helper-orderly.R @@ -1,6 +1,6 @@ options(outpack.schema_validate = requireNamespace("jsonvalidate", quietly = TRUE) && - utils::packageVersion("jsonvalidate") >= "1.4.0", + packageVersion("jsonvalidate") >= "1.4.0", orderly_index_progress = FALSE)