From 9d722176363458fb61c27356241d13a61764f7d0 Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Thu, 17 Oct 2024 11:38:13 +0100 Subject: [PATCH] fix: erroneous version comparison - fixes a comparison between strings to a comparison between a numeric_version and a string (a valid op). - Uses getNamespaceVersion as clearer and part of base API as well as still being performant. --- R/aab-rstudio-detect.R | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/R/aab-rstudio-detect.R b/R/aab-rstudio-detect.R index 19a3726e..b844d73a 100644 --- a/R/aab-rstudio-detect.R +++ b/R/aab-rstudio-detect.R @@ -36,11 +36,7 @@ rstudio <- local({ if (d$api) { ns <- asNamespace("rstudioapi") d$ver <- if (d$api) ns$getVersion() - - # Pull version from namespace rather than via `utils::packageVersion()` - # to avoid slowdown (see https://github.com/r-lib/rlang/pull/1657 and - # https://github.com/r-lib/rlang/issues/1422) - new_api <- ns[[".__NAMESPACE__."]][["spec"]][["version"]] >= "0.17.0" + new_api <- getNamespaceVersion(ns) >= "0.17.0" d$desktop <- if (new_api) ns$getMode() else ns$versionInfo()$mode }