diff options
| author | Paulb23 | 2016-03-17 20:35:04 +0000 |
|---|---|---|
| committer | Rémi Verschelde | 2016-04-02 22:11:37 +0200 |
| commit | 1369b38d85b7669674eca450ae6933fed2caf277 (patch) | |
| tree | a29e1258df62996f1c80ea14669271fff30f09bb /scene/gui/text_edit.cpp | |
| parent | 68b7f9d87a06defc484daee04d8a85e016ef8279 (diff) | |
| download | godot-1369b38d85b7669674eca450ae6933fed2caf277.tar.gz godot-1369b38d85b7669674eca450ae6933fed2caf277.tar.zst godot-1369b38d85b7669674eca450ae6933fed2caf277.zip | |
Fixed highlighting when word occurs as substring first
(cherry picked from commit 9c0e1524e56a3d38bf5ab281939770e806ac24e9)
Diffstat (limited to 'scene/gui/text_edit.cpp')
| -rw-r--r-- | scene/gui/text_edit.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index be3792ad7..6ab142c0f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3198,16 +3198,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; |
