diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-04-29 15:56:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 15:56:08 +0200 |
commit | f6e29addd433130100061935b9a2b8f6de38254b (patch) | |
tree | 1056d82ebec62b8b5877b3e5e2e76b4bae866b10 | |
parent | 58435b0c917fd93d4244ed672e7fadd076dae608 (diff) | |
parent | 4a82390aafdf464a2776b1df3a75b47783d42b04 (diff) |
Merge pull request #37846 from CaptainProton42/text-edit-undo-stack-size
Add "undo_max_stack_size" property to TextEdit
-rw-r--r-- | scene/gui/text_edit.cpp | 7 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 2d63d86048..9ee7456d26 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -6215,6 +6215,10 @@ void TextEdit::_push_current_op() { current_op.type = TextOperation::TYPE_NONE; current_op.text = ""; current_op.chain_forward = false; + + if (undo_stack.size() > undo_stack_max_size) { + undo_stack.pop_front(); + } } void TextEdit::set_indent_using_spaces(const bool p_use_spaces) { @@ -7239,6 +7243,8 @@ void TextEdit::_bind_methods() { GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec", 3); ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/text_edit_idle_detect_sec", PropertyInfo(Variant::FLOAT, "gui/timers/text_edit_idle_detect_sec", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater")); // No negative numbers. + GLOBAL_DEF("gui/common/text_edit_undo_stack_max_size", 1024); + ProjectSettings::get_singleton()->set_custom_property_info("gui/common/text_edit_undo_stack_max_size", PropertyInfo(Variant::INT, "gui/common/text_edit_undo_stack_max_size", PROPERTY_HINT_RANGE, "0,10000,1,or_greater")); // No negative numbers. } TextEdit::TextEdit() { @@ -7318,6 +7324,7 @@ TextEdit::TextEdit() { current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; + undo_stack_max_size = GLOBAL_GET("gui/common/text_edit_undo_stack_max_size"); undo_stack_pos = nullptr; setting_text = false; last_dblclk = 0; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index ef8c39d32f..ac8eb5da1d 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -306,6 +306,7 @@ private: List<TextOperation> undo_stack; List<TextOperation>::Element *undo_stack_pos; + int undo_stack_max_size; void _clear_redo(); void _do_text_op(const TextOperation &p_op, bool p_reverse); |