getSourceEditorContext() does not work correctly with visual markdown editing when called from addin

Open
#200 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
api

Research direction

Start by reproducing the addin calls to getActiveDocumentContext and getSourceEditorContext with the cursor in R Markdown text and code chunks during visual editing. Compare those results with source editing mode and the R console; done when the relevant context, including the currently shown Rmd path, is returned consistently outside code chunks.

Written by the indexing model from the issue text.

Description

The visual markdown editing feature of the RStudio preview version really looks great! When testing it I found out, however, that getActiveDocumentContext and getSourceEditorContext don't work correctly.

I have an RStudio Addin in my RTutor package that calls getSourceEditorContext in order to get the path of the currently shown Rmd file. In source editing mode that works fine. In the visual markdown editing that only works if the cursor is in a code chunk, if the cursor is on some Rmd text then getSourceEditorContext returns NULL.

Note that if the cursor is in the R console getSourceEditorContext() also works well, even when called from the addin. The problem thus only arises if the cursor is in some none-chunk line in the Rmd file.

The bug ocurred with both the CRAN and Github version of rstudioapi.

Dominant language
R
Stars
175
Forks
37
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/rstudioapi

All issues in rstudio/rstudioapi

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.