Maniphest T68068

Text editor undo system, undo step limiting behavior
Confirmed, NormalDESIGN

Assigned To
Campbell Barton (campbellbarton)
Authored By
Campbell Barton (campbellbarton)
Aug 1 2019, 2:11 PM
Tags
  • BF Blender
  • Text Editor
  • Papercut
  • Core
  • Undo
Subscribers
Campbell Barton (campbellbarton)
dan grauer (kromar)
Kai Jægersen (kaio)
Pratik Borhade (PratikPB2123)
Robert Moore (robmoore)
StrictlyIncreasing (StrictlyIncreasing)

Description

Currently having a linear undo stack has a limitation which is most obvious with text undo.

Typing a character uses a single undo step, meaning if you are working in 3D sculpting for eg, then type a short paragraph over 32 characters - you'll loose all your undo steps.

Proposed solution is for undo systems to support counting their undo steps separately, so text editing operations wouldn't use up undo steps for edits in other modes.

Event Timeline

Campbell Barton (campbellbarton) renamed this task from Design for undo systems co-existing usefully to Text editor undo system, undo step limiting behavior.Aug 1 2019, 2:11 PM
Campbell Barton (campbellbarton) lowered the priority of this task from 90 to Normal.
Campbell Barton (campbellbarton) created this task.
Campbell Barton (campbellbarton) mentioned this in T68061: Text Editor Module.
dan grauer (kromar) added a subscriber: dan grauer (kromar).Aug 7 2019, 11:27 PM
Dalai Felinto (dfelinto) added a project: Text Editor.Aug 13 2019, 2:57 PM
Dalai Felinto (dfelinto) moved this task from Backlog to Long Term on the Text Editor board.
Bastien Montagne (mont29) added a project: Pipeline, Assets & I/O.Jun 11 2020, 5:24 PM
Bastien Montagne (mont29) moved this task from Backlog to Long-Term - Official on the Pipeline, Assets & I/O board.Jun 11 2020, 6:03 PM
StrictlyIncreasing (StrictlyIncreasing) added a subscriber: StrictlyIncreasing (StrictlyIncreasing).Jun 18 2020, 3:26 AM

Somewhat unrelated but if you go ahead with this maybe you could also create a local undo stack for the knife tool as well, that only stays in memory for the duration of the operation.

Campbell Barton (campbellbarton) moved this task from Long Term to Papercuts on the Text Editor board.Jun 18 2020, 3:26 PM
Campbell Barton (campbellbarton) moved this task from Papercuts to Long Term on the Text Editor board.
Campbell Barton (campbellbarton) moved this task from Long Term to Papercuts on the Text Editor board.
Campbell Barton (campbellbarton) added a project: Papercut.
Campbell Barton (campbellbarton) moved this task from Papercuts to Long Term on the Text Editor board.Jun 20 2020, 4:54 AM
Bastien Montagne (mont29) removed a project: Datablocks and Libraries.Aug 14 2020, 11:47 AM
Kai Jægersen (kaio) added a subscriber: Kai Jægersen (kaio).Sep 12 2020, 1:18 AM
Bastien Montagne (mont29) edited projects, added Core; removed Pipeline, Assets & I/O.Feb 16 2021, 6:02 PM
Bastien Montagne (mont29) moved this task from Backlog to Long-Term - Official on the Core board.Feb 16 2021, 6:06 PM
Robert Moore (robmoore) added a subscriber: Robert Moore (robmoore).Feb 22 2021, 10:49 PM

An Undo modal/dialog could help. Its "Tagged Undo" subsystem/layer/tree/table could use time-stamps and context tags to distinguish undo actions. This way, for example, Text Editor events wouldn't have to be undone just so that 3D-View actions can be undone, even if they took place about the same time. Not all undoable actions show up in the Info area, so for this implementation, 'Alt+z' would display a dialog of user input events, listed by tag (context) columns, with check boxes in each action cell and for each individual context-based event group.

The dialog table header would be something like this: | Context | User | Input Event(s) | Activity |

There would also be a "Recover" button to undo the checked events. The user would be able to set the name of their activity in Blender at a given time, again by toggling the table display via 'Alt+z'. Uses for this would be activity logging for reports, or self-audit. An undo action group, determined by the 'Recover' event in the 'Alt+z' dialog would be logged as a single complete (undoable) reference action, no matter the checked (and unchecked) events rolled back (and not).

Action-tracking like this becomes like recording a Vim or Neovim macro. It might be an easier step toward resolving Undo trees. It is both better and worse than full implementation of an Undo tree. Better, because it can get the user to focus on what they want to repeat, but also worse because unrecorded Undo information may be lost or limited to linear undo.

Beyond this, for the UI, the use of a built-in Mercurial/Git/Subversion/GNU Bazaar in a bpy.context-sensitive processing implementation could help. Using any one of them might even be the least trouble to implement, since they already exist, are stable, and are maintained globally by interested third parties. Depending on the footprint and resource/speed hit the Blender runtime might take, I'd be very much inclined in this case not to reinvent anything, and instead suggest going for a built-in versioning system. To the extent possible, the smaller context and event logs would want to be kept in memory, even with SSD speeds, rather than being repeatedly written to and read from disk like the larger processes and events might.

A versioning system in this situation could take all-blend-data snapshots from time to time and also record only events and user actions, instead of bpy.data snapshots. I have rarely used versioning systems to store binary content, so I don't know how much this affects the ideas mentioned here. To pick one might require comparable, Blender-specific speed tests on each of the revision systems.

For the GUI, an alternative or addition to a dialog launched by Alt+z (configured in User Preferences), the key combination could be used to maximise the space_outliner.py area. This would be useful because the Data API would keep Undo records in a new subtree listing in the Outliner.

Robert Moore (robmoore) added a comment.EditedFeb 23 2021, 9:53 AM
blender/source$ ack undo|wc -l # 2460
blender/source$ ack Undo|wc -l # 932
blender/source$ ack info|wc -l # 5233
blender/source$ ack Info|wc -l # 2959
blender/source$ ack log|wc -l # 2298
blender/source$ ack Log|wc -l # 516

Preferences > Keymap > Text > Text (Global) does not seem to have an entry for Ctrl+z/Undo. Nor does Preferences > Keymap > Text > Text Generic.

Do you think that implementing User Preferences-based control of bpy.ops.ed.undo() (differential undo) or a Text Editor-specific Undo action (something using stateful undo bpy.data.text.[...]) could be an incremental improvement?

Bastien Montagne (mont29) added a project: Undo.Jul 20 2021, 9:41 AM
Bastien Montagne (mont29) moved this task from Backlog to Under Discussion on the Undo board.Jan 27 2022, 5:58 PM
Pratik Borhade (PratikPB2123) added a subscriber: Pratik Borhade (PratikPB2123).Mar 13 2022, 2:17 PM