godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.93k stars 21.15k forks source link

Multi caret undo breaks after typing too many characters #80624

Open gokiburikin opened 1 year ago

gokiburikin commented 1 year ago

Godot version

v4.1.stable.official [970459615]

System information

Windows 10

Issue description

When replacing many instances of text with multi caret editing, if you replace it by typing too many characters the undo stack breaks with an error message scene/gui/text_edit.cpp:4002 - Condition "!undo_stack_pos->prev()" is true. Breaking.

Steps to reproduce

Multi caret select a lot of text and replace it by typing new text. Attempt to undo.

https://github.com/godotengine/godot/assets/3820082/8b605188-6de3-450c-a9e8-82b2b4ace3f8

Minimal reproduction project

N/A

TheSofox commented 11 months ago

Tagging @Paulb23 since they implemented Multi-caret editing.

TheSofox commented 11 months ago

Found the cause, basically the undo queue hits it maximum. Setting is in Project Settings -> GUI -> Common -> Text Edit Undo Stack Max Size: https://docs.godotengine.org/en/stable/classes/class_projectsettings.html#class-projectsettings-property-gui-common-text-edit-undo-stack-max-size

By default it's 1024. Each individual character change counts as an action. So if you've got 20 line multi carat, you can type just over 50 characters in one go before you hit the limit and undoing the operations results in an error. (20 x 50 =1000)

You can raise this limit (though you may need to restart to take effect) and it'll be able to take more characters. I'm not sure if this counts as a solution.

Paulb23 commented 11 months ago

it's a known limitation, increasing the undo queue is the best solution for now, without having to re-write undo / redo in TextEdit