diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 07f1bdf8e5e..44eb29b7754 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2544,22 +2544,19 @@ void TextEdit::_gui_input(const Ref &p_gui_input) { if (cc == 0 && cursor.line > 0) { cursor_set_line(cursor.line - 1); cursor_set_column(text[cursor.line].length()); - break; + } else { + while (cc > 0) { + bool ischar = _is_text_char(text[cursor.line][cc - 1]); + + if (prev_char && !ischar) + break; + + prev_char = ischar; + cc--; + } + cursor_set_column(cc); } - while (cc > 0) { - - bool ischar = _is_text_char(text[cursor.line][cc - 1]); - - if (prev_char && !ischar) - break; - - prev_char = ischar; - cc--; - } - - cursor_set_column(cc); - } else if (cursor.column == 0) { if (cursor.line > 0) { @@ -2608,21 +2605,18 @@ void TextEdit::_gui_input(const Ref &p_gui_input) { if (cc == text[cursor.line].length() && cursor.line < text.size() - 1) { cursor_set_line(cursor.line + 1); cursor_set_column(0); - break; + } else { + while (cc < text[cursor.line].length()) { + bool ischar = _is_text_char(text[cursor.line][cc]); + + if (prev_char && !ischar) + break; + prev_char = ischar; + cc++; + } + cursor_set_column(cc); } - while (cc < text[cursor.line].length()) { - - bool ischar = _is_text_char(text[cursor.line][cc]); - - if (prev_char && !ischar) - break; - prev_char = ischar; - cc++; - } - - cursor_set_column(cc); - } else if (cursor.column == text[cursor.line].length()) { if (cursor.line < text.size() - 1) {