Text Editor: Missing undo for text operators when in edit mode #80611

Closed
opened 2020-09-09 00:16:33 +02:00 by Kai Jægersen · 8 comments

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.87

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-07 08:12, hash: b351607996
Worked: Some time before binary diffing was implemented maybe?

Short description of error

Note: This is about text editor operators, nothing to do with Text objects in the viewport.

Custom text operators that modify the text (text.body, text.write(), etc.) are missing undo steps IFF an object is in edit mode.
When an object is in object mode, however, the undo works as expected.

Text operators implemented in C work fine. Assuming the solution is letting custom operators push or tag undo like internal ones.

Exact steps for others to reproduce the error

  1. Load the example blend. The cube will be in edit mode.
  2. Run script. A new button "Modify Body" is placed in the header of Text Editor.
  3. Click the button a few times.
  4. Try to undo (doesn't work)
  5. Toggle to Object mode and do steps 3 and 4 again (undo works)

example.blend

**System Information** Operating system: Windows-10-10.0.18362-SP0 64 Bits Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 441.87 **Blender Version** Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-07 08:12, hash: `b351607996` Worked: Some time before binary diffing was implemented maybe? **Short description of error** *Note: This is about text editor operators, nothing to do with Text objects in the viewport.* Custom text operators that modify the text (text.body, text.write(), etc.) are missing undo steps IFF an object is in edit mode. When an object is in object mode, however, the undo works as expected. Text operators implemented in C work fine. Assuming the solution is letting custom operators push or tag undo like internal ones. **Exact steps for others to reproduce the error** 1. Load the example blend. The cube will be in edit mode. 2. Run script. A new button "Modify Body" is placed in the header of *Text Editor*. 3. Click the button a few times. 4. Try to undo (doesn't work) 5. Toggle to Object mode and do steps 3 and 4 again (undo works) [example.blend](https://archive.blender.org/developer/F8855670/example.blend)
Author

Added subscriber: @KaiJaegersen

Added subscriber: @KaiJaegersen

Added subscriber: @mano-wii

Added subscriber: @mano-wii

The undo system is confusing.
There are many reports on global undo that seem to be related.
The text editor has its own undo context, but apparently it doesn't work on python operators.
Maybe this system needs to be rewritten (there are already tasks designed to do this #68068, #71735)

I'm not sure if this is something that can be fixed in a short time.

The undo system is confusing. There are many reports on global undo that seem to be related. The text editor has its own undo context, but apparently it doesn't work on python operators. Maybe this system needs to be rewritten (there are already tasks designed to do this #68068, #71735) I'm not sure if this is something that can be fixed in a short time.
Author

Thanks, I've been looking for those tasks. I wasn't sure if there was a specific report for this.

A workaround to getting undo to work in edit mode for custom operators is to register a Macro which defines two operators:

  1. An internal operator eg. TEXT_OT_insert
  2. My custom python operator

The result is that the macro is able to piggyback the undo pushed by TEXT_OT_insert.
While this works it requires a macro operator, and the code just becomes confusing for others to read.

Thanks, I've been looking for those tasks. I wasn't sure if there was a specific report for this. A workaround to getting undo to work in edit mode for custom operators is to register a `Macro` which defines two operators: 1. An internal operator eg. `TEXT_OT_insert` 2. My custom python operator The result is that the macro is able to piggyback the undo pushed by `TEXT_OT_insert`. While this works it requires a macro operator, and the code just becomes confusing for others to read.
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Added subscriber: @ideasman42

Added subscriber: @ideasman42

We need to expose undo for text operators written in Python, currently in C this is done explicitly, it would be nice to avoid begin/end calls to the undo system although I don't see good way around this (that doesn't further complicate undo).

Added design task which links to this task.

We need to expose undo for text operators written in Python, currently in C this is done explicitly, it would be nice to avoid begin/end calls to the undo system although I don't see good way around this (that doesn't further complicate undo). Added design task which links to this task.

Closed as duplicate of #80864

Closed as duplicate of #80864
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
4 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#80611
No description provided.