-
Notifications
You must be signed in to change notification settings - Fork 130
Description
System details:
Positron and OS details:
Positron Version: 2025.03.0 (Universal) build 116
Code - OSS Version: 1.96.0
Commit: 7f0f938
Date: 2025-03-01T18:51:44.014Z
Electron: 32.2.6
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Darwin arm64 24.3.0
Interpreter details:
R 4.4.2 + Quarto 1.7.13
Describe the issue:
(I'm not sure if this is a Quarto extension issue or a Positron issue—it's weird behavior nonetheless.)
On macOS, the keystroke ⌥- (alt/option + -) inserts an en-dash (–). In Positron (inheriting from RStudio settings), ⌥- inserts the left assignment operator <-. That's all great and fine—there's rarely any reason to use proper en-dashes in R code (beyond things like typographically correct plot titles).
Positron includes a keybinding setting in the R language pack called 'R: Insert the "<-" assignment operator', which contains this:
{
"key": "alt+-",
"command": "r.insertLeftAssignment",
"when": "editorTextFocus && editorLangId == 'r' || editorTextFocus && quarto.document.languageId == 'r'"
}It makes Positron insert a <- in R scripts and Quarto documents that use R.
However, it seems to be a little too aggressive in when it is enabled. Here are some little videos to illustrate what's happening…
Steps to reproduce the issue:
On macOS, in a new Quarto document with no code chunks, alt+- inserts an en-dash as expected:
part-1.mov
If a Python chunk is added, alt+- continues to insert an en-dash, both in the code chunk and in the Markdown area. This is good and expected—<- isn't a thing in Python:
part-2.mov
If an R chunk is added, alt+- inserts a <- in the R chunk, which is good and expected, BUT it also inserts a <- outside of the chunk in the Markdown. This is unexpected.
part-3.mov
If the R chunk is removed, alt+- returns to working with en-dashes:
part-4.mov
Essentially, if there's an R chunk anywhere in a Quarto document, alt+- inserts <- in all contexts (YAML, Markdown, R). If the document contains chunks with multiple languages (e.g., R and Python), alt+- will insert <- in the other language chunks too. The existence of an R chunk enables the left assignment shortcut for the whole document.
Expected or desired behavior
It would be nice if the alt+- shortcut could be limited to only R code chunks. My current workaround is to use a systemwide keyboard shortcut (;enn) that expands to an en-dash—I just have to remember to use it when working in Markdown in Positron 🤷♂️