notebook icon indicating copy to clipboard operation
notebook copied to clipboard

JN 7 → Code Folding starts at the first line regardless the type

Open MichalRIcar opened this issue 11 months ago • 16 comments

Hi,

Jupyter Notebook 7:

I would like to propose to be able to fold any cell by the first line of text regardless its type.

Reasoning of it is that in many scenarios we have a cell with certain description and funcionality in some type of representation, flow.

Once user of a Notebook reads instructions, it is not necessary to keep the whole cell unfolded, actually it is very beneficial to allow to fold the whole cell keeping only the first row (likely a Title of a cell).

E.g. cell worthy to read and then fold it to see only a title "The Generator X" Cell:

# The Generator X
# This function produces...
A = FunctionX()

# Callable Output
#...

Best, Michal

MichalRIcar avatar Jul 28 '23 14:07 MichalRIcar

Thank you @MichalRIcar for submitting this issue! As we use CodeMirror for code folding, this might be either a change to configuration or an improvement to CodeMirror.

RRosio avatar Aug 01 '23 16:08 RRosio

The way I read it, this basically requests what was already implemented in https://github.com/jupyterlab/jupyterlab/pull/14141

Screenshot from 2023-08-01 17-45-39

@MichalRIcar is this correct?

krassowski avatar Aug 01 '23 16:08 krassowski

Hi,

I will use an example from JN 6 with this feature on via codefolding extension:

Before Folding image

After Folding image

MichalRIcar avatar Aug 01 '23 17:08 MichalRIcar

As we can see, the "old" codefolding allowed to fold any cell by its first line regardless of its type..very useful feature in notebook presentation.

MichalRIcar avatar Aug 01 '23 17:08 MichalRIcar

Sorry but I still do not see how it differs from what was implemented in https://github.com/jupyterlab/jupyterlab/pull/14141.

krassowski avatar Sep 05 '23 17:09 krassowski

@krassowski, thank you for pointing this out. You are absolutely correct that these two options are almost identical. However, I can only access the cell collapsing feature through the 'View' menu by selecting 'Collapse Selected Code' or 'Collapse All Code.' Perhaps I'm just missing some optional feature in Jupyter Notebook 7 because I don't see any dynamic option inside a cell to fold a whole code cell - similarly as we see in the example above?

Or idea behind this feature in JN7 is to not provide code folding in a code cell and rather forcing a user to use View option given by dev reasons? Originally (intuitively), I though it will be among these.. image

MichalRIcar avatar Sep 07 '23 11:09 MichalRIcar

You can click on the blue bar next to the cell:

click-clock

This is somewhat documented in JupyterLab user guide but not in notebook itself. I think we should move the Notebook content User Guide to this repo (recreating videos using playwright) and then just embed it in JupyterLab docs.

krassowski avatar Sep 07 '23 11:09 krassowski

Right! That was the first thing I tried and it doesn't work even though I have code folding allowed everywhere in Settings..

MichalRIcar avatar Sep 07 '23 11:09 MichalRIcar

Is this dynamic bar folding connected with some other setup in the JN Settings?

MichalRIcar avatar Sep 07 '23 11:09 MichalRIcar

Can you provide a recording and check if there are any errors in the JS console?

krassowski avatar Sep 07 '23 11:09 krassowski

Absolutely, I've just checked that in JL it works indeed..but JN no luck. I've also checked that JN is not given by a browser - both Chrome and Edge behave same - i.e. no bar code folding behavior.

MichalRIcar avatar Sep 07 '23 11:09 MichalRIcar

JS concole has these errors and tons of warnings image

MichalRIcar avatar Sep 07 '23 11:09 MichalRIcar

Warnings image

MichalRIcar avatar Sep 07 '23 11:09 MichalRIcar

https://github.com/jupyter/notebook/assets/62614119/73e5a70d-5754-4342-bb34-6d447578af29

MichalRIcar avatar Sep 07 '23 12:09 MichalRIcar

The collapsing issue might be similar to the one reported in https://github.com/jupyter/notebook/issues/7020

jtpio avatar Sep 07 '23 12:09 jtpio

This active code folding is broken on my machine. I just installed the latest jupyter notebook.

tmatsuzawa avatar Mar 20 '24 18:03 tmatsuzawa