From 4cc3fbeaffcffe5fe834b2b2afda18661836f769 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Thu, 17 Mar 2016 19:37:19 +0000 Subject: [PATCH 1/2] Fixed highliting with shift and mouse --- scene/gui/text_edit.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index df272c97a53..59f9ee4a739 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -644,10 +644,7 @@ void TextEdit::_notification(int p_what) { Point2 cursor_pos; // get the highlighted words - String highlighted_text; - if (is_selection_active()) { - highlighted_text = get_selection_text(); - } + String highlighted_text = get_selection_text(); for (int i=0;i Date: Thu, 17 Mar 2016 20:35:04 +0000 Subject: [PATCH 2/2] Fixed highlighting when word occurs as substring first --- scene/gui/text_edit.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 59f9ee4a739..0fc8e39fefb 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3219,16 +3219,22 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc p_from_column = 0; } - // match case - col = p_search.findn(p_key, p_from_column); + while (col == -1 && p_from_column <= p_search.length()) { + // match case + col = p_search.findn(p_key, p_from_column); - // whole words only - if (col != -1) { - if (col > 0 && _is_text_char(p_search[col-1])) { - col = -1; - } else if (_is_text_char(p_search[col+p_key.length()])) { - col = -1; + // whole words only + if (col != -1) { + p_from_column=col; + + if (col > 0 && _is_text_char(p_search[col-1])) { + col = -1; + } else if (_is_text_char(p_search[col+p_key.length()])) { + col = -1; + } } + + p_from_column+=1; } } return col;