cocalc icon indicating copy to clipboard operation
cocalc copied to clipboard

Notebook scrolling after clearing output

Open novoselt opened this issue 1 year ago • 3 comments

With recent changes Jupyter notebooks are so much better in maintaining their position without unneeded scrolling!

In particular - if one has the top border going through a code cell and clicks "Restart and run all...", the scrolling position is maintained exactly, i.e. if the output after running again has the same size, one will see on the screen exactly the same portion of the notebook, which is very pleasant when specifically looking for changes in a complicated output.

But if the top border goes through the output, there is a jump. It makes sense - the output has to be deleted as the first step, so it is not possible to avoid shifting up or down. At the moment the notebook scrolls down and some portion of the next code cell becomes the top of the view, I am not sure what position exactly. Perhaps "the top output" is deleted and the next cell is shifted up?

What I think would make even more sense, is to shift "the cell of the top output" down, so that its bottom becomes the view cutoff and its output becomes visible once it is computed. There still will be a jump in the scrolling position, but a little bit backwards and it would be easier to reorient in the notebook.

Another option is to wait for the output that was at the top to be computed and then try to put it into the same position. I am not certain this is a good idea, however: that output may take considerable amount of time to appear and the user may have scrolled away somewhere else already

novoselt avatar Dec 12 '23 00:12 novoselt

Could you include an easy example to reproduce this...

williamstein avatar Dec 12 '23 02:12 williamstein

It was not that easy. It seems that behaviour is a bit random with shorter notebooks, while with the one including relatively long code and mix of plots and dataframes it seemed to be consistent. The attached notebook has a mix of text and plot output and seems to be somewhat consistent. If I scroll to the red plot like this image then "Restart and run all..." keeps the same scroll position. But if I shift it like this image then "Restart and run all..." leads to image i.e. I see the bottom half of the code cell which is under the red plot. While the old position is close, I found it to be a bit disorienting, because it scrolls to a place in the notebook which I have not looked at recently (if I am going from top to bottom), so it is not clear right away how far I am from the old position and where I should scroll.

It is weird that I cannot attach ipynb, but zip is OK... tests.zip

novoselt avatar Dec 12 '23 04:12 novoselt

Thanks! I know how much work good examples like this are to make, but they are critical for being able to work on the code.

One other obvious question -- what does JupyterLab do? That's always important in terms of user expectations.

williamstein avatar Dec 12 '23 05:12 williamstein