You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a wrapper that navigate to a file location of a potentially unsaved document. Therefore with
rstudioapi::getSourceEditorContext()$path#> ""
However the file has a Rstudio id.
Therefore, I was wondering if documentOpen() could have an id parameter, so it would be possible to open an unsaved document to a specified location.
navigate_to_unsaved_file<-function(regex) {
file_content<-rstudioapi::getSourceEditorContext()$contentline_regex<-stringr::str_which(file_content, regex)
rstudioapi::documentOpen(
id=rstudioapi::getSourceEditorContext()$id,
line=line_regex[1] # just using the first match for simplicity and example
)
}
Edit: using rstudioapi::setCursorPosition() works. However, it doesn't move focus to the required place (if my focus was on console, it remains this way) Maybe adding a moveCursor argument to setCursorPosition() would work?
The text was updated successfully, but these errors were encountered:
olivroy
changed the title
FR: Could documentOpen() have an id parameter
FR: Add an id parameter to documentOpen()Aug 8, 2023
I am trying to write a wrapper that navigate to a file location of a potentially unsaved document. Therefore with
However the file has a Rstudio
id
.Therefore, I was wondering if
documentOpen()
could have anid
parameter, so it would be possible to open an unsaved document to a specified location.For reference, I am trying to achieve quarto-dev/quarto-cli#5335 with rstudioapi
Thanks
Edit: with an unsaved file,
Edit: using
rstudioapi::setCursorPosition()
works. However, it doesn't move focus to the required place (if my focus was on console, it remains this way) Maybe adding amoveCursor
argument tosetCursorPosition()
would work?The text was updated successfully, but these errors were encountered: