Reading in text from document via rstudioapi?

Hello! My first post here. I'm not an experienced programmer, just a grad student trying to make life easier. With that introduction...

I'm trying my hand at creating an add-in. I would like to read in some text based on the cursor position within an Rmarkdown document. While I am able to pull in the cursor position with rstudioapi::primary_selection(getActiveDocumentContext())$range$start[1] , my attempts to pull in actual text are not successful. The following leaves me with only "":

active_row <- rstudioapi::primary_selection(getActiveDocumentContext())$range$start[1]
rstudioapi::document_range(c(active_row,1), c(active_row,9))

I have tried consulting the documentation I could find but have been coming up empty. Any thoughts?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.