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
Could rstudioapi include a method for obtaining the editor context by document ID? AFAICT, getSourceEditorContext() and getActiveDocumentContext() are the only way to get the current selection and contents for a document. In theory, one could use navigateToFile() to activate the required editor, read the source editor context, then switch back to the previously active editor... but there are a few problems:
navigateToFile() is currently asynchronous, which introduces subtle timing issues that mean that one cannot simply call
navigateToFile("code.R")
getSourceEditorContext()
since the second call will almost certainly return the editor context of the document that was active, not the context from the desired file code.R. (This will be fixed by API for document activation rstudio#8938)
The text was updated successfully, but these errors were encountered:
Could rstudioapi include a method for obtaining the editor context by document ID? AFAICT,
getSourceEditorContext()
andgetActiveDocumentContext()
are the only way to get the current selection and contents for a document. In theory, one could usenavigateToFile()
to activate the required editor, read the source editor context, then switch back to the previously active editor... but there are a few problems:It's not possible to switch to an editor by context ID, meaning it may not be possible to switch back to the previously open editor (Allow switching to source editor by document ID #250)
navigateToFile()
is currently asynchronous, which introduces subtle timing issues that mean that one cannot simply callnavigateToFile("code.R") getSourceEditorContext()
since the second call will almost certainly return the editor context of the document that was active, not the context from the desired file
code.R
. (This will be fixed by API for document activation rstudio#8938)The text was updated successfully, but these errors were encountered: