-
Notifications
You must be signed in to change notification settings - Fork 22
Support R chunk formatting in Jupyter/Positron notebooks #432
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
Conversation
Co-authored-by: kv9898 <[email protected]>
…tebooks Co-authored-by: kv9898 <[email protected]>
This reverts commit 5b8c1f0.
|
Thanks a lot for taking a look at this! It does work quite well but we're adding a newline at the end of chunks that shouldn't be there: Screen.Recording.2025-10-22.at.11.02.32.movruff explicitly trims this newline: https://github.com/astral-sh/ruff/blob/6271fba1e1c01c9c49a360b1084217955145bce6/crates/ruff_server/src/server/api/requests/format.rs#L121-L134 Would you like to also take a look at this issue? It would involve detecting cell URIs in the format request handler to trim the result before creating edits. I'm also happy to take it from here, just let me know. |
|
@lionel- I also noted this, but i thought this was the desired behaviour. I would love to have a look but it will probably take me (or claude) a while to find out which part of the codebase is responsible for this. Is there anything that stops us from mimicking ruff's solution? BTW: i've also fixed the 2 PRs to ark. |
* Initial plan * Fix empty line at end of R chunks in notebooks - Add check for vscode-notebook-cell scheme in document_formatting - Remove trailing newline for notebook cells to avoid empty line - Add test cases for notebook cell formatting - Range formatting already handled correctly Co-authored-by: kv9898 <[email protected]>
|
@lionel- I think copilot did a pretty good job fixing the end-of-chunk empty line issue. Note: if the empty line at then end is the only thing to be fixed, my current version would ignore it. But it won't add new empty lines, and, if there are other problems to be fixed, the trailing empty line would be removed. |
|
I notice that if there is an existing trailing newline, it is still preserved. If there is more, they are all stripped. I think this is behaviour from the notebook extension, probably to avoid removing line breaks when editing: Screen.Recording.2025-10-23.at.12.01.08.movThanks a lot for this contribution @kv9898, I'm very happy to have notebook cell support! |
Currently, R chunks in Jupyter/Positron
.ipynbnotebooks cannot be formatted by Air. I brought up this issue in #405 but it was closed as it was considered "out of scope for Air" for Air. I opened another issue in posit-dev/positron#10059.However, it turned out that by adding the following line to
lsp.tswould enable Air to work for notebooks quite seamlessly:So I thought it would be worth writing a PR to enable this feature.