positron
positron copied to clipboard
Support language keyboard shortcuts in Quarto chunks
With an open R file, cmd+shift+m will automatically insert R pipe (|>). However, in an R code chunk within a Quarto document, the same shortcut instead opens the PROBLEMS panel. The VS Code keyboard shorcuts doc indicates that this is the expected behavior for this keybinding in VS Code:
However, it feels like Quarto chunks should prioritize language-specific key bindings. I intentionally left this issue title a bit vague in case there are other bindings that don't function as expected from within quarto chunks.
Currently our rules for the pipe shortcut say editorLangId == r:
https://github.com/posit-dev/positron/blob/de7666b74f2e3f2adfca059b6dc841ae3c6e9d86/extensions/positron-r/package.json#L32-L36
I don't know what Quarto currently gives us for editorLangId, given that it can be R, Python, etc.
Just to link these up, we are tracking some other related issues about Quarto and language features:
- #1572
- #1805
Some research ...
I just created a new Quarto document in positron and added an R chunk. With the cursor inside that chunk, I inspected context keys. editorLangId is 'quarto' and editorTextFocus is true.
https://code.visualstudio.com/api/references/when-clause-contexts#inspect-context-keys-utility
This came up during usability testing with @gadenbuie today, and is a reason he shies away from using Quarto in Positron and/or VS Code.
This came up in our private beta here: https://github.com/posit-dev/positron-beta/discussions/90
Should we do something easy and quick in the short term, like add the pipe shortcut to the RStudio keymap?
After #3523 we have the shortcuts for |> and <- provided for Quarto files in the RStudio Keymap but in the long term we would like to support language keyboard shortcuts generally in Quarto chunks.
In the source mode it currently works like a charm! However, as noted in #4368, it still doesn't work in the visual mode
Quick hack around: modify the shortcuts directly (change when expression) to editorTextFocus && editorLangId == 'quarto' || editorTextFocus && editorLangId == 'r'. Works nicely for the pipe shortcut at least :)
Quick hack around: modify the shortcuts directly (change when expression) to
editorTextFocus && editorLangId == 'quarto' || editorTextFocus && editorLangId == 'r'. Works nicely for the pipe shortcut at least :)
Thank you for your suggestion! I tried your proposed solution but sadly it didn't work for me (in the source mode it works as before, but in visual mode nothing happens)
Verified Fixed
Positron Version(s) : 2024.12.0-96 Workbench Version(s): OS Version(s) : Windows 11
Test scenario(s)
Keyboard shortcuts now work in Quarto document as expected.