positron icon indicating copy to clipboard operation
positron copied to clipboard

Auto translation of equal sign `=` to assign operator `<-`

Open abduazizR opened this issue 1 year ago • 4 comments

System details:

Positron and OS details:

Positron Version: 2024.08.0 (Universal) build 5 Code - OSS Version: 1.91.0 Commit: Unknown Date: 2024-08-06T17:08:14.498Z (2 wks ago) Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.6.0

Interpreter details:

R 4.4.1

Describe the issue:

I noticed that in R scripts, whenever I copy something like x = 8 and paste it in another place in the script, the = transforms automatically to <-

image image image image

I am unsure if it's a bug or if something is incorrectly specified in my settings.

Thanks

abduazizR avatar Aug 21 '24 20:08 abduazizR

If you are using styler, this is probably just an artifact of styler getting to format your code on paste. I think it changes = to <-

You can turn this setting off if you want to otherwise keep using styler (but if you run format document it will probably also convert equals to assignment then too)

Screenshot 2024-08-21 at 5 03 06 PM

DavisVaughan avatar Aug 21 '24 21:08 DavisVaughan

Thanks for the super quick response. Is there a way to keep the formatter but prevent it from making this translation?

abduazizR avatar Aug 21 '24 21:08 abduazizR

@abduazizR I'm not familiar with styler but it doesn't seem like there's an option you could set unfortunately: https://stackoverflow.com/questions/50660401/use-instead-of-for-assignment-when-styling-r-code-with-styler

We're planning to implement our own formatter. We'll need a way to declare the assignment op, and also auto-detect it from the file.

lionel- avatar Aug 22 '24 07:08 lionel-

Related to #4009 and #2251

juliasilge avatar Aug 22 '24 16:08 juliasilge

With https://github.com/posit-dev/positron/pull/7199 we have removed the styler integration. Instead, we encourage users to install the Air extension, and soon (this milestone) Positron will also bundle the Air extension natively, so you won't even have to install it.

Air does not perform the = to <- auto translation (at least not right now, and if we did do it, this is probably something you could opt out of), so I consider this resolved.

DavisVaughan avatar Apr 11 '25 12:04 DavisVaughan