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

Cell info when collapsed #6512

Closed
dbuendiab opened this issue Jun 8, 2019 · 7 comments · Fixed by #14141
Closed

Cell info when collapsed #6512

dbuendiab opened this issue Jun 8, 2019 · 7 comments · Fixed by #14141

Comments

@dbuendiab
Copy link

I've been user of iPython Notebooks and Jupyter Notebooks for a long time, and now I'm trying the JupyterLab environment, and I feel it's really cool.

The collapse of a cell is a very good feature, specially if you write a lot of cells in the same Notebook, as I often do.

My suggestion is to keep the first line of the cell visible somehow, all the time or just when you hover over the three big dots of the collapsed cell.

This would permit to keep a info line, just a comment or so, like the name of the class or function (class Dot: or def quadratic(x, y):), or just a comment on the content of the hidden cell (## Heavy geo calc here), so the hidden cell content will be known without the need of open it.

Thank you in advance,

@tgrout
Copy link

tgrout commented Aug 6, 2019

This would be immensely helpful if this were implemented. Please and Thank You.

@fdeheeger
Copy link

I used to use the "toggle code" extension to benefit from such a behavior.

The current "toggle code" implementation does not recognize (sadly) the first comment of the cell as a "toggle cell" point... Not sure if it could be something actionable from that parameter of the cell editor.

@sergiocaccamo
Copy link

Before it was collapsible headings and code folding that was missing, now, this is the only remaining feature that keeps me from completely switching from jupyter notebook.
I agree with the above. The first comment line in a code block should be considered as a collapsible anchor, much like codefolding in jupyter_contrib_nbextensions does.
From: codefolding - jupyter_contrib_nbextensions
"The algorithm simply looks for a comment in the first line and allows folding in the rest of the cell."

@pintail-xyz
Copy link

pintail-xyz commented Aug 24, 2022

It seems there are two separate functionalities here - collapsing cells - which leaves only "..." displayed - and code folding, which allows blocks of code to be folded into a single line. Both collapsing cells and code folding are implemented in jupyterlab, but the code folding implementation is less capable than the one that was present in the old nbextensions version of code folding.

As @sergiocaccamo points out, it would be great if the jupyterlab version of code folding did the same thing as the jupyter notebooks one by checking for a comment in the first line of a cell which can be used as an anchor point for folding the rest of the cell.

Possibly this should be a new github issue since this one is about collapsing cells rather than code folding. Alternatively @dbuendiab perhaps you could alter the title of this issue to something like "code folding - fold entire cell if first line is a comment" if what I'm describing matches what you'd like to see here?

Edit: worth pointing out that the code that does first line comment folding in the original extension is just 14 lines long. Hopefully for someone with a better understanding of Codemirror than me this would actually be a very straightforward change!

@mpacer
Copy link
Member

mpacer commented Dec 16, 2022

@afshin (not sure who to ping around Codemirror changes these days… sorry if this is the wrong ping!)

Just wanted to give a plus one on @pintail-xyz's analysis… this does indicate a regression from classic notebook (one that I specifically ran into in trying again to use jupyter lab just today).

Not knowing at all what a cell holds when running it is far too dangerous for me to feel comfortable using to condense longer notebooks (even for code that I've written), so the current cell-collapsing functionality is entirely a non-starter for me.

However, it is helpful to be able to have a single commented line that could fold an entire cell (in a way that was persisted across saves). It is was able to stand-in as a description for the entire collection of code that was folded away and gives a sense of place and assurance around what is being run.

I also agree that the title of this issue could be improved by distinguishing between cold-folding and cell collapsing; but I think (as @pintail-xyz suggests) it's fine to keep the cell-collapsing behaviour as it is… but for parity it is crucial to bring back the code-folding feature where an entire cell can be represented by an initial line comment.

@afshin
Copy link
Member

afshin commented Dec 19, 2022

@mpacer, thanks for the ping!

This is something we should validate in JL4 and NB7 as a feature parity issue, cc: @JohanMabille @fcollonval @jtpio might have some insight.

@jtpio
Copy link
Member

jtpio commented Dec 20, 2022

JL4 and NB7 as a feature parity issue

Likely this could be implemented in JupyterLab 4, and Notebook 7 would inherit it directly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.