Text editor undo system, undo step limiting behavior #68068

Open
opened 2019-08-01 14:11:21 +02:00 by Campbell Barton · 9 comments

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.

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.
Campbell Barton self-assigned this 2019-08-01 14:11:21 +02:00
Author
Owner

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Campbell Barton changed title from Design for undo systems co-existing usefully to Text editor undo system, undo step limiting behavior 2019-08-01 14:12:09 +02:00
Member

Added subscriber: @DanielGrauer

Added subscriber: @DanielGrauer

Added subscriber: @NoBlahBlah

Added subscriber: @NoBlahBlah

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.

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.

Added subscriber: @KaiJaegersen

Added subscriber: @KaiJaegersen
Member

Added subscriber: @rdmo

Added subscriber: @rdmo
Member

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.

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.
Member
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.

2021-02-User_Preferences_Keymaps_Text_Editor_Undo.png

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?

``` 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**. ![2021-02-User_Preferences_Keymaps_Text_Editor_Undo.png](https://archive.blender.org/developer/F9830547/2021-02-User_Preferences_Keymaps_Text_Editor_Undo.png) 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?
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#68068
No description provided.