From a11a691b174c0ddb72328cf8dae6d6f82f5ad885 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Sat, 23 Dec 2017 14:47:04 +0000 Subject: Fixed keyboard word selection when at the start/end of line, issue 14675 --- scene/gui/text_edit.cpp | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 07f1bdf8e5..44eb29b775 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; - } - - while (cc > 0) { - - bool ischar = _is_text_char(text[cursor.line][cc - 1]); + } else { + while (cc > 0) { + bool ischar = _is_text_char(text[cursor.line][cc - 1]); - if (prev_char && !ischar) - break; + if (prev_char && !ischar) + break; - prev_char = ischar; - cc--; + prev_char = ischar; + cc--; + } + cursor_set_column(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; - } - - while (cc < text[cursor.line].length()) { - - bool ischar = _is_text_char(text[cursor.line][cc]); + } 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++; + if (prev_char && !ischar) + break; + prev_char = ischar; + cc++; + } + cursor_set_column(cc); } - cursor_set_column(cc); - } else if (cursor.column == text[cursor.line].length()) { if (cursor.line < text.size() - 1) { -- cgit v1.2.3