-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R code formatting #5534
Comments
Do you have styler installed? We currently depend on it (#2251). |
Yes: packageVersion("styler")
#> [1] ‘1.10.3’ |
I noticed that this report plus #5531 were both on Windows, so I just tried formatting ("Format Document" and "Format Selection") with: Positron Version: 2024.12.0 (system setup) build 80 This did work for me correctly. So no clue yet! Question 1Can you make sure your R kernel log level is debug? And then can try to format and visit the Output channel for "R 4.4.0: Kernel" (or your equivalent) to confirm you don't see any messages like:
Question 2Can you confirm it is only the formatter that isn't working? We set that up here, so I'd be interested in knowing if both commands and tasks are provided correctly. Can you confirm that you can successfully use:
Question 3We have a new kernel supervisor in the latest release. Can you turn it off, restart Positron, and check if you still see the problem? |
I am reporting some of my confirmations here. Sorry I don't quite understand some of the instructions you gave, so I can only confirm the parts I understand. Question 1My previous R kernel log level is warn (default), I change it to info. I downloaded the R 4.4.0, but I donot know how to visit the Output channel for "R 4.4.0: Kernel" (or your equivalent) . so I cannot confirm this instruction. Question 2I do not have enough knowledge to understand those code you give in that new link. so I cannot comfirm this instruction. But ctrl + shift + n for creating New R File is working for me. Also, ctrl + shift + c and alt + - are working for me. Those are shortcuts I often used, so I can confirm that they work well. Question 3I turned off kernel supervisor and restarted Positron. This is my settings.json:, you can find that I changed R kernel log level and turned off kernel supervisor.
Unfortunately, after doing all this, ctrl + shift + a is still not working. Hopefully someone else can bring good news. |
@zwallen Can you share if you can format regular |
@strengejacke and @lijiaqi-github are you all working with an untitled |
It seems to work for saved files, despite the indention is not correct. In this video, I edited the script (removed whitespace around format.mp4For unsaved files, nothing happens. |
Yes, I tested this in a new unsaved R file, Like @strengejacke said, formatting in a saved file seems to work. |
Ah gotcha, OK! It's quite a coincidence that we have had multiple folks run into this at once, but yep, currently the styler-based formatter only works on "real" files, not on untitled files that have never been saved to disk. This is currently as expected. We have some MAJOR improvements in formatting coming along shortly, so I don't think we're going to put much more effort into our stopgap solution using styler in the meantime. Thank you so much for the reports, and keep your eyes open for some major steps forward in R formatting soon! 🙌 |
I'm not sure if I'm missing something, but is it possible to format R code? I have enabled settings:
And there are some defined keybindings:
But it doesn't seem to work.
Setup
Positron Version: 2024.12.0 (system setup) build 80
Code - OSS Version: 1.93.0
Commit: c3c4896
Date: 2024-11-26T02:46:23.686Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.26100
R 4.4.2
E.g. this code can't be formatted.
Result in VSCode and RStudio:
The text was updated successfully, but these errors were encountered: