Skip to content
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

Code folding does not work for Python or R code cells #2924

Open
jmcphers opened this issue Apr 29, 2024 · 3 comments
Open

Code folding does not work for Python or R code cells #2924

jmcphers opened this issue Apr 29, 2024 · 3 comments
Labels
area: core Issues related to Core category. bug Something isn't working
Milestone

Comments

@jmcphers
Copy link
Collaborator

Positron Version:

2024.04.0 build 1570

Steps to reproduce the issue:

Add a Python code cell to a .py file:

# %%
msg = "Hello World"
print(msg)

And/or an R code cell to a .R file:

#+
msg <- "Hello World"
print(msg)

What did you expect to happen?

These code cells should be foldable.

We have a folding provider which detects them (implemented here: https://github.com/posit-dev/positron/blob/main/extensions/positron-code-cells/src/folding.ts), but it has been temporarily disabled because enabling it turns off all other code folding in these scripts. Details here:

#2902

The best fix for this issue would be for the R and Python language packs to contribute their own folding providers (e.g. #18). The editor is smart enough to combine folding ranges from multiple providers.

Alternately, we could patch the editor so that it is able to merge built-in indentation based folding ranges with ranges supplied by an extension.

@kv9898
Copy link

kv9898 commented Oct 31, 2024

I'm trying to include a fix to this in my PR: posit-dev/ark#615, in addition to foldable nested comment sections.

However, I'm not quite sure how the code cell should end?

@lionel-
Copy link
Contributor

lionel- commented Oct 31, 2024

@kv9898 The code cells extend up to the next cell fence. See https://code.visualstudio.com/docs/python/jupyter-support-py

#+ cell a
"this"

"is"

"cell a"

#+ cell b
"now starts cell b until the end of the doc or next cell"

@kv9898
Copy link

kv9898 commented Oct 31, 2024

@kv9898 The code cells extend up to the next cell fence. See https://code.visualstudio.com/docs/python/jupyter-support-py

#+ cell a
"this"

"is"

"cell a"

#+ cell b
"now starts cell b until the end of the doc or next cell"

Thank you @lionel- ! I have added support for R code cells in ark in posit-dev/ark#615.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to Core category. bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants