summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-09-14 11:57:42 +0200
committerGitHub <noreply@github.com>2021-09-14 11:57:42 +0200
commitd039f4af140cedd08da203c33a425d9a75b224d5 (patch)
treec12e9b3ba756d6a359576936b96658bb628fd79a /scene/gui
parent76a7ee88d227ab53e320d76595ad902f3ab13ef2 (diff)
parentc5d7ae7920605ef5753f1838e83c015df339929a (diff)
Merge pull request #52185 from Paulb23/nested-complex-ops
Allow nested complex ops in TextEdit
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/text_edit.cpp13
-rw-r--r--scene/gui/text_edit.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 6bcbedfceb..06dfc31621 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2731,6 +2731,8 @@ void TextEdit::insert_line_at(int p_at, const String &p_text) {
}
void TextEdit::insert_text_at_caret(const String &p_text) {
+ begin_complex_operation();
+
delete_selection();
int new_column, new_line;
@@ -2740,6 +2742,8 @@ void TextEdit::insert_text_at_caret(const String &p_text) {
set_caret_line(new_line, false);
set_caret_column(new_column);
update();
+
+ end_complex_operation();
}
void TextEdit::remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
@@ -3024,13 +3028,20 @@ void TextEdit::menu_option(int p_option) {
/* Versioning */
void TextEdit::begin_complex_operation() {
_push_current_op();
- next_operation_is_complex = true;
+ if (complex_operation_count == 0) {
+ next_operation_is_complex = true;
+ }
+ complex_operation_count++;
}
void TextEdit::end_complex_operation() {
_push_current_op();
ERR_FAIL_COND(undo_stack.size() == 0);
+ complex_operation_count = MAX(complex_operation_count - 1, 0);
+ if (complex_operation_count > 0) {
+ return;
+ }
if (undo_stack.back()->get().chain_forward) {
undo_stack.back()->get().chain_forward = false;
return;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 525464c302..b1226f2aff 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -304,6 +304,7 @@ private:
bool undo_enabled = true;
int undo_stack_max_size = 50;
+ int complex_operation_count = 0;
bool next_operation_is_complex = false;
TextOperation current_op;