multi-user sync-aware undo

38 views
Skip to first unread message

William Stein

unread,
Sep 3, 2016, 10:19:20 PM9/3/16
to sage-cloud, sage-cloud-members
Hi SMC Users/devs,

Today -- motivated by a challenge from a c9.io developer at a recent
meetup in Seattle -- I finally implemented multi-user sync-aware full
document undo/redo, at least for code editors, sage worksheets, and
Jupyter notebooks. If you've ever edited a file, worksheet, or
Jupyter notebook at the same time as somebody else, and you hit
control+z (or click undo) right after *they* type something, you would
have undid *their* last thing. That's because the undo/redo would use
the underlying Codemirror editor's undo/redo functionality. I wrote
a new implementation of undo/redo built on top of the realtime
multiuser sync functionality. Instead of undoing the last change (or
changes if you undo or redo multiple times) to the document, it undoes
*only* the changes that you made during this session.

For Jupyter notebooks in SageMathCloud this has an interesting side
effect. Vanilla Jupyter itself doesn't have any global undo --
instead they have a local undo in each cell, which you could only use
via the keyboard and. With this change, now Jupyter notebooks in SMC
have a global undo: make some changes in any cell(s), move cells
around, delete cells, etc., then click undo/redo or use the keyboard
to undo/redo, and the undo should undo everything you actually did
across all cells.

-- William


--

Best Regards,
William Stein

CEO, SageMath, Inc.

Aaron Tresham

unread,
Sep 4, 2016, 1:39:05 PM9/4/16
to sage-cloud, sage-clou...@googlegroups.com
My students constantly delete text cells in Sage worksheets - often the text cells containing the questions of my assignments. In the past, "undo" would not recover the deleted text. I would go back in the history and copy and paste it back in for them. Now I am able to undo the deletion of text cells (insert choir of angels).

In fact, in the past if one deleted the horizontal gray line right above a text cell, the text input would be deleted, while the text output would still display. Then when one later tried to edit the text, he would double-click on the text output and nothing would happen (i.e., the input had been deleted, so you could not open and edit the input). Now, when I delete the line before text, the whole text cell is deleted (input and output). I'm assuming this is all part of the same change to SMC.

Thank you! This will be very helpful for me.

Aaron

William Stein

unread,
Sep 4, 2016, 1:41:19 PM9/4/16
to sage-cloud, sage-cloud-members
On Sun, Sep 4, 2016 at 10:39 AM, Aaron Tresham <atre...@gmail.com> wrote:
> My students constantly delete text cells in Sage worksheets - often the text
> cells containing the questions of my assignments. In the past, "undo" would
> not recover the deleted text. I would go back in the history and copy and
> paste it back in for them. Now I am able to undo the deletion of text cells
> (insert choir of angels).

Awesome -- that makes sense. Before the undo stack was handled entirely by
codemirror, which had a lot of potential difficult to address issues.
Now it's just the well-defined sync state, handled in a different way.
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/47b4efbb-5b8d-4608-a878-a30dfb76848f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages