summaryrefslogtreecommitdiff
path: root/scene/gui/text_edit.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2016-03-17 22:26:40 +0100
committerRémi Verschelde <remi@verschelde.fr>2016-03-17 22:26:40 +0100
commit3adc5a45ab8a6a486ee2713f1ef60370c0d94cbe (patch)
treef87ad1a6b873619cb6a9096504bd20455276baa6 /scene/gui/text_edit.cpp
parent63aafb3f4891a66b06e65ba1f47d958fcd92ed7f (diff)
parent9c0e1524e56a3d38bf5ab281939770e806ac24e9 (diff)
Merge pull request #4082 from Paulb23/word_highlighting
Fixes for Word highlighting
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r--scene/gui/text_edit.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index df272c97a5..0fc8e39fef 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<visible_rows;i++) {
@@ -667,7 +664,7 @@ void TextEdit::_notification(int p_what) {
// check if line contains highlighted word
int highlighted_text_col = -1;
- if (is_selection_active()) {
+ if (highlighted_text.length() != 0) {
highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, 0);
}
@@ -3222,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) {
+ p_from_column=col;
- // 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;
+ 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;