From edadb46bd445f0cf776ccca5206c66d62ac9baeb Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 13 Jun 2016 16:40:28 -0300 Subject: [PATCH] Fix TextEdit cursor position after undo remove text It was going to where the text started, now it goes to where the text ends. (cherry picked from commit 831ae2d510b4ae87a1ff5f828ab817640269dca2) --- scene/gui/text_edit.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 0e8e0d60b21..b70a359b463 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3748,8 +3748,13 @@ void TextEdit::undo() { } } - cursor_set_line(undo_stack_pos->get().from_line); - cursor_set_column(undo_stack_pos->get().from_column); + if (undo_stack_pos->get().type == TextOperation::TYPE_REMOVE) { + cursor_set_line(undo_stack_pos->get().to_line); + cursor_set_column(undo_stack_pos->get().to_column); + } else { + cursor_set_line(undo_stack_pos->get().from_line); + cursor_set_column(undo_stack_pos->get().from_column); + } update(); }