Skip to content

Commit

Permalink
Do not contribute "r.sourceCurrentFile" affordances in an R package (
Browse files Browse the repository at this point in the history
…#4567)

Addresses #1359 

I can't think of good reasons why people would in fact want any of these
affordances in an R package. Even without them, you can still do
something like <kbd>Cmd</kbd>+<kbd>Enter</kbd> to get a function
defined, as well as of course the better/recommended options like
`devtools::load_all()`, etc.

### QA Notes

After this change,

- when you are in an `.R` file but _not_ in an R package, you get the
command to source your current file on the editor action bar, in the
context menu, and via the keybinding.
- when you _are_ in an R package in an `.R` file, you do not see this
command in any of these three spots.

I kept the command in the command palette because it is used [in
testing](https://github.com/posit-dev/positron/blob/de05c42d65938e0dfc7755d67d59eda49957ef2e/test/smoke/src/areas/positron/dataexplorer/largeDataFrame.test.ts#L99)
(the testing workspaces look like R packages) and it's not _super_
prominent for users there.
  • Loading branch information
juliasilge authored Sep 4, 2024
1 parent a5dd049 commit 08986c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extensions/positron-r/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@
"command": "r.sourceCurrentFile",
"key": "ctrl+shift+enter",
"mac": "cmd+shift+enter",
"when": "editorLangId == r"
"when": "editorLangId == r && !isRPackage"
},
{
"command": "r.insertSection",
Expand Down Expand Up @@ -485,7 +485,7 @@
"command": "r.sourceCurrentFile",
"group": "R",
"title": "%r.command.sourceCurrentFile.title%",
"when": "editorLangId == r"
"when": "editorLangId == r && !isRPackage"
},
{
"command": "r.rmarkdownRender",
Expand All @@ -500,7 +500,7 @@
"group": "navigation@0",
"icon": "$(play)",
"title": "%r.command.sourceCurrentFile.title%",
"when": "resourceLangId == r && !isInDiffEditor"
"when": "resourceLangId == r && !isInDiffEditor && !isRPackage"
},
{
"command": "r.rmarkdownRender",
Expand Down

0 comments on commit 08986c1

Please sign in to comment.