From 08986c170f3cea9ddda6415387ae6d85b99cbcda Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 4 Sep 2024 08:38:30 -0700 Subject: [PATCH] Do not contribute `"r.sourceCurrentFile"` affordances in an R package (#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 Cmd+Enter 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. --- extensions/positron-r/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/positron-r/package.json b/extensions/positron-r/package.json index f96e5b37dc9..9b48cabb0db 100644 --- a/extensions/positron-r/package.json +++ b/extensions/positron-r/package.json @@ -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", @@ -485,7 +485,7 @@ "command": "r.sourceCurrentFile", "group": "R", "title": "%r.command.sourceCurrentFile.title%", - "when": "editorLangId == r" + "when": "editorLangId == r && !isRPackage" }, { "command": "r.rmarkdownRender", @@ -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",