Skip to content

[BUG] Addin to put selected text between ns() doesn't work #1190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
howardbaik opened this issue Apr 1, 2025 · 2 comments
Open

[BUG] Addin to put selected text between ns() doesn't work #1190

howardbaik opened this issue Apr 1, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@howardbaik
Copy link

Describe the bug

I tried to insert ns() using the RStudio Addin and got this message: Your version of RStudio does not support modifyRange. This message is ultimately caused by hasFun <- rstudioapi::hasFun(fun) returning FALSE.

To Reproduce
Steps to reproduce the behavior:

  1. Write a string of text that you want to put inside ns(). (i.e. "test-ns")
  2. Inside RStudio, click Addins -> Put selected text into between ns()

Expected behavior

I'm expecting the addin to put ns() around my text (i.e. ns("test-ns"))

Screenshots

Image

session info

─ Session info ───────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.3 (2025-02-28 ucrt)
 os       Windows 11 x64 (build 26100)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United States.utf8
 ctype    English_United States.utf8
 tz       America/New_York
 date     2025-04-01
 rstudio  2024.12.1+563 Kousa Dogwood (desktop)
 pandoc   NA
 quarto   ERROR: Unknown command "TMPDIR=C:/Users/hbaik/AppData/Local/Temp/Rtmp46KzaM/file59cc64be47a0". Did you mean command "install"? @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\quarto.exe

─ Packages ───────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 attempt       0.3.1   2020-05-03 [1] CRAN (R 4.4.3)
 cachem        1.1.0   2024-05-16 [1] CRAN (R 4.4.3)
 cli           3.6.4   2025-02-13 [1] CRAN (R 4.4.3)
 config        0.3.2   2023-08-30 [1] CRAN (R 4.4.3)
 devtools      2.4.5   2022-10-11 [1] CRAN (R 4.4.3)
 digest        0.6.37  2024-08-19 [1] CRAN (R 4.4.3)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.4.3)
 fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.3)
 fs            1.6.5   2024-10-30 [1] CRAN (R 4.4.3)
 glue          1.8.0   2024-09-30 [1] CRAN (R 4.4.3)
 golem         0.5.1   2024-08-27 [1] CRAN (R 4.4.3)
 htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.3)
 htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.4.3)
 httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.4.3)
 later         1.4.1   2024-11-27 [1] CRAN (R 4.4.3)
 lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.3)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.3)
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.4.3)
 mime          0.13    2025-03-17 [1] CRAN (R 4.4.3)
 miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.4.3)
 pkgbuild      1.4.7   2025-03-24 [1] CRAN (R 4.4.3)
 pkgload       1.4.0   2024-06-28 [1] CRAN (R 4.4.3)
 profvis       0.4.0   2024-09-20 [1] CRAN (R 4.4.3)
 promises      1.3.2   2024-11-28 [1] CRAN (R 4.4.3)
 purrr         1.0.4   2025-02-05 [1] CRAN (R 4.4.3)
 R6            2.6.1   2025-02-15 [1] CRAN (R 4.4.3)
 Rcpp          1.0.14  2025-01-12 [1] CRAN (R 4.4.3)
 remotes       2.5.0   2024-03-17 [1] CRAN (R 4.4.3)
 rlang         1.1.5   2025-01-17 [1] CRAN (R 4.4.3)
 rstudioapi    0.17.1  2024-10-22 [1] CRAN (R 4.4.3)
 sessioninfo   1.2.3   2025-02-05 [1] CRAN (R 4.4.3)
 shiny         1.10.0  2024-12-14 [1] CRAN (R 4.4.3)
 urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.4.3)
 usethis       3.1.0   2024-11-26 [1] CRAN (R 4.4.3)
 vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.3)
 xtable        1.8-4   2019-04-21 [1] CRAN (R 4.4.3)
 yaml          2.3.10  2024-07-26 [1] CRAN (R 4.4.3)

 [1] C:/Users/hbaik/AppData/Local/R/win-library/4.4
 [2] C:/Program Files/R/R-4.4.3/library

──────────────────────────────────────────────────────────────────────────────────────
Warning message:
In system2("quarto", "-V", stdout = TRUE, env = paste0("TMPDIR=",  :
  running command '"quarto" TMPDIR=C:/Users/hbaik/AppData/Local/Temp/Rtmp46KzaM/file59cc64be47a0 -V' had status 1

Additional context

Two things:

  1. I am hoping this bug gets fixed and I can assign a keyboard shortcut to this RStudio Addin.
  2. I investigated why rstudioapi::hasFun("modifyRange") returned FALSE in hasFun("modifyRange") returns FALSE rstudio/rstudioapi#317, and discovered that it was an RStudio bug. From conversation with @kevinushey, we should use this function instead of hasFun():
is_modifyRange_available <- function() {
  if (!rstudioapi::isAvailable()) return(FALSE)

  version_info <- rstudioapi::versionInfo()
  required_version <- package_version("XXX")  # XXX = next release of RStudio

  return(!is.null(version_info$version) &&
         version_info$version >= required_version)
}
@howardbaik howardbaik added the bug Something isn't working label Apr 1, 2025
@ColinFay
Copy link
Member

ColinFay commented Apr 1, 2025

Hello,

Your version of RStudio seems to be to old to support the feature of modifying text from the editor.

Can you update RStudio and try again?

@howardbaik
Copy link
Author

Hi Colin,

It looks like I'm using the newest version of RStudio:

Image

Which version of RStudio are you using? Does the RStudio Addin work on your end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants