summaryrefslogtreecommitdiff
path: root/scene/gui/text_edit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r--scene/gui/text_edit.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index a3f59b54fc..aa4310da46 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -883,7 +883,7 @@ void TextEdit::_notification(int p_what) {
}
// give visual indication of empty selected line
- if (selection.active && line >= selection.from_line && line <= selection.to_line) {
+ if (selection.active && line >= selection.from_line && line <= selection.to_line && char_margin >= xmargin_beg) {
int char_w = cache.font->get_char_size(' ').width;
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, get_row_height()), cache.selection_color);
}
@@ -4467,31 +4467,44 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
int pos_from = 0;
int last_pos = -1;
- while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) {
- if (p_search_flags & SEARCH_BACKWARDS) {
+ while (true) {
- if (last_pos > from_column)
- break;
- pos = last_pos;
+ while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) {
- } else {
+ if (p_search_flags & SEARCH_BACKWARDS) {
- if (last_pos >= from_column) {
+ if (last_pos > from_column)
+ break;
pos = last_pos;
- break;
+
+ } else {
+
+ if (last_pos >= from_column) {
+ pos = last_pos;
+ break;
+ }
}
+
+ pos_from = last_pos + p_key.length();
}
- pos_from = last_pos + p_key.length();
- }
+ bool is_match = true;
+
+ if (pos != -1 && (p_search_flags & SEARCH_WHOLE_WORDS)) {
+ //validate for whole words
+ if (pos > 0 && _is_text_char(text_line[pos - 1]))
+ is_match = false;
+ else if (pos + p_key.length() < text_line.length() && _is_text_char(text_line[pos + p_key.length()]))
+ is_match = false;
+ }
+
+ if (is_match || last_pos == -1 || pos == -1) {
+ break;
+ }
- if (pos != -1 && (p_search_flags & SEARCH_WHOLE_WORDS)) {
- //validate for whole words
- if (pos > 0 && _is_text_char(text_line[pos - 1]))
- pos = -1;
- else if (_is_text_char(text_line[pos + p_key.length()]))
- pos = -1;
+ pos_from = pos + 1;
+ pos = -1;
}
if (pos != -1)