rstudio / rstudioapi

Safely access RStudio's API (when available)
http://rstudio.github.io/rstudioapi
Other
165 stars 35 forks source link

FR: getDocumentContent() #281

Closed olivroy closed 11 months ago

olivroy commented 11 months ago

Hi, I was wondering if it was possible to add getDocumentContent()

For unsaved files, I don't know how to read lines

or readDocumentLines

kevinushey commented 11 months ago

Does rstudioapi::getSourceEditorContext() give you what you need? You can pass it an id as retrieved from rstudioapi::documentId().

olivroy commented 11 months ago

Oh, yes sorry. I didn't realise it returned a list. This does the trick indeed.

rstudioapi::getSourceEditorContext()$content