jupyter-server / jupyter_ydoc

Jupyter document structures for collaborative editing using Yjs/pycrdt
https://jupyter-ydoc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
29 stars 17 forks source link

Undo/redo does not scroll to selection #240

Open krassowski opened 3 months ago

krassowski commented 3 months ago

Description

This is one of the most frustrating things for me when using JupyterLab and it prevents me from working productively with larger files - see https://github.com/jupyterlab/jupyterlab/issues/15102

Reproduce

See https://github.com/jupyterlab/jupyterlab/issues/15102

Expected behavior

Editor scrolls on undo/redo if the new selection is outside of the viewport.

Context

This was just fixed in y-codemirror.next: https://github.com/yjs/y-codemirror.next/pull/34 but jupyter_ydoc does not use that and has its own integration of undo manager.

krassowski commented 3 months ago

It looks like we need something like this._undoManager.on('stack-item-popped', this._onStackItemPopped). For now I would propose to add it for text documents as in notebooks the behaviour is more complex.

Then, I wonder how is selection set currently if _onStackItemPopped is not implemented?

krassowski commented 2 months ago

This is one of the most frustrating things for me when using JupyterLab and it prevents me from working productively with larger files

Well, I'm not alone: https://stackoverflow.com/questions/78818736/follow-changes-with-the-mouse-cursor-when-pressing-ctrl-z-z-undo-redo-in-jup

krassowski commented 2 months ago

I do not have rights to tag issues here, but if I could I would tag it with https://github.com/jupyter-server/jupyter_ydoc/labels/help%20wanted