posit-dev / posit-dev/positron
Identify if focus is console or text editor via `rstudioapi::getActiveDocumentContext()`: `id` and `path`
Nobody has claimed this yet.
- 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:
- https://github.com/posit-dev/ark/pull/237
- https://github.com/posit-dev/positron/issues/2191
- https://github.com/posit-dev/positron/issues/2571 - focuses on
$id - https://github.com/posit-dev/positron/pull/2582
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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