8

I am using Jupyter Notebook (from Anaconda JupyterLab) on Windows 10 and tried to undo/redo changes in the selected cell. However, I can only undo/redo changes in the whole notebook.

For example, I edited cell#1 then cell#2. Say I want to undo changes in cell#1, so I go to cell#1 and press Control+Z, it will however undo the change in cell#2.

My friend using Mac doesn't have this issue. Are there any settings for this? I searched online and didn't find anyone who has the same problem. It is so weird!

blackraven
  • 5,284
  • 7
  • 19
  • 45
s99090
  • 83
  • 1
  • 5
  • 1
    There is now [a pull request addressing this issue](https://github.com/jupyterlab/jupyterlab/pull/10949) - please do test it out on Binder and contribute feedback to the discussion. – krassowski Aug 31 '21 at 09:35
  • I updated the answer since JupyterLab 3.2 is out with a setting to restore the old behaviour. – krassowski Oct 14 '21 at 20:05

2 Answers2

15

This global undo/redo is a new feature that enables Real Time Collaboration which was added in JupyterLab 3.1. It is indeed sub-optimal for many use cases.

JupyterLab 3.2 allows to disable notebook-wide history tracking (see issue 10791 nad PR 10949), but with a caveat: when moving cells you may loose the undo history, which is why the setting is marked as experimental (it requires more work to be exposed or enabled by a default). To get the selective undo/redo please add:

{
    "experimentalDisableDocumentWideUndoRedo": true
}

in Advanced Settings EditorNotebook, save, and reload JupyterLab (if you use it in a browser a refresh should suffice).

You can also stick with JupyterLab 3.0 if this is a deal breaker. To downgrade you can use pip:

pip install "jupyterlab<3.1"

or conda:

conda install -c conda-forge "jupyterlab<3.1"

but I would recommend sticking with JupyterLab 3.2 and trying out the new setting so you can contribute to the discussion (if you experience any problems or believe it could be improved).

krassowski
  • 13,598
  • 4
  • 60
  • 92
  • 1
    I see! my friend (3.0) and I (3.1) are using different versions of jupyter lab. Thanks for the help! – s99090 Aug 13 '21 at 13:54
  • https://github.com/jupyterlab/jupyterlab/issues/10791#issuecomment-979544958 – thistleknot Nov 26 '21 at 00:47
  • As commented on the issue you very likely use 3.1 and not 3.2. – krassowski Nov 26 '21 at 09:22
  • So the feature is *required* for collaborative editing, right? That probably means it will stay default... Well, another reason to just stick with `jupyter-notebook`... – jena May 11 '22 at 13:08
4

Recently I've also experienced the same annoying problem. I'm adding a picture here to illustrate how to disable "document-wide undo/redo".

JupyterLab -> Settings -> Advanced Settings Editor -> Notebook -> Ctrl-F to find "undo" -> check the box "Experimental settings to...".

After that remember to close and re-open JupyterLab!

enter image description here

blackraven
  • 5,284
  • 7
  • 19
  • 45