posit-dev / posit-dev/positron

Identify if focus is console or text editor via `rstudioapi::getActiveDocumentContext()`: `id` and `path`

Open
#3,941 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement lang: r
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 11h
Merged PRs (30d)
206

Description

I want to know if I'm currently in the console or in a text editor. I used to use getActiveDocumentContext() to determine this and either send code to the console or add the code to the file I am editing. Right now, running this function from the console and text editor return the same list of values. I see that $id has been identified as an issue (below), but not sure about the other items ($path, etc).

I saw these issues and PRs that seem related:

I'm not sure how it all works under the hood but the VS Code context keys editorFocus and terminalFocus might be able to help.

Here's a comparison between Positron (great name btw) and RStudio

  • image

Contributor guide

Open the contributing guide

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.

Research direction

Start by tracing how rstudioapi::getActiveDocumentContext() is exposed in Positron and compare its console and text-editor results, using the related issues and pull requests as context. Check the VS Code editorFocus and terminalFocus context keys; done means documenting or implementing a reliable distinction and clarifying the expected id and path values.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, typescript, vscode
Domain
desktop, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.