Skip to content

Commit

Permalink
Use new Quarto context keys in keyboard shortcuts (#5451)
Browse files Browse the repository at this point in the history
Addresses #1955 together with
quarto-dev/quarto#608

The Quarto PR provides new context keys for the main language of a
Quarto document (for example, R or Python) and we can consume those to
provide keyboard shortcuts.

There are really only a couple of R ones that we want right now which
means that there is no real change here in an R `.qmd` in behavior
compared to what is in the RStudio Keymap. 🙈 However, I think this is
still worth getting in since we've gone to the trouble of figuring it
out, it lets us offer these without the RStudio Keymap being on, we can
offer them _only_ in R `.qmd` files (right now, these also show up in
Python `.qmd` files if you have the RStudio Keymap on), and we can use
this infrastructure in the future.

I did remove these from the RStudio Keymap just to clean things up, but
it wouldn't hurt _a lot_ to keep them, if there is some reason I am not
thinking of? If we do want to remove them, we'll need to do a Quarto
release and update the bundled Quarto VS Code extension version in this
PR to keep these keybindings functional.

### QA Notes

With the new version of the Quarto extension (updated here), you can use
the keyboard shortcuts for the pipe and assignment operator in R Quarto
documents but not Python ones:

- <kbd>Alt</kbd>+<kbd>-</kbd> to get you `<-`
- <kbd>Cmd/Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>M</kbd> to get you `|>`
  • Loading branch information
juliasilge authored Nov 27, 2024
1 parent 54cbc06 commit f53a9d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
8 changes: 4 additions & 4 deletions extensions/positron-r/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
"command": "r.insertPipe",
"key": "ctrl+shift+m",
"mac": "cmd+shift+m",
"when": "editorLangId == r"
"when": "editorLangId == r || quarto.document.languageId == r"
},
{
"command": "r.insertPipeConsole",
Expand All @@ -382,7 +382,7 @@
"command": "r.insertLeftAssignment",
"key": "alt+-",
"mac": "alt+-",
"when": "editorLangId == r"
"when": "editorLangId == r || quarto.document.languageId == r"
},
{
"command": "r.insertLeftAssignmentConsole",
Expand Down Expand Up @@ -466,7 +466,7 @@
{
"category": "R",
"command": "r.insertPipe",
"when": "editorLangId == r"
"when": "editorLangId == r || quarto.document.languageId == r"
},
{
"category": "R",
Expand All @@ -476,7 +476,7 @@
{
"category": "R",
"command": "r.insertLeftAssignment",
"when": "editorLangId == r"
"when": "editorLangId == r || quarto.document.languageId == r"
},
{
"category": "R",
Expand Down
16 changes: 0 additions & 16 deletions extensions/positron-rstudio-keymap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,6 @@
"when": "config.rstudio.keymap.enable && editorLangId == r",
"command": "r.sourceCurrentFileWithEcho"
},
{
"mac": "cmd+shift+m",
"win": "ctrl+shift+m",
"linux": "ctrl+shift+m",
"key": "ctrl+shift+m",
"when": "config.rstudio.keymap.enable && editorLangId == quarto",
"command": "r.insertPipe"
},
{
"mac": "alt+-",
"win": "alt+-",
"linux": "alt+-",
"key": "alt+-",
"when": "config.rstudio.keymap.enable && editorLangId == quarto",
"command": "r.insertLeftAssignment"
},
{
"mac": "ctrl+alt+left",
"win": "ctrl+alt+left",
Expand Down
2 changes: 1 addition & 1 deletion product.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
},
{
"name": "quarto.quarto",
"version": "1.114.0",
"version": "1.118.0",
"repo": "https://github.com/quarto-dev/quarto/tree/main/apps/vscode",
"metadata": {
"id": "a1be81fc-0f3a-4f2e-92ee-3fdc7ab96c73",
Expand Down

0 comments on commit f53a9d1

Please sign in to comment.