summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramakarenko <alexey-makarenko@hotmail.com>2019-09-02 15:15:55 +0300
committeramakarenko <alexey-makarenko@hotmail.com>2019-09-02 15:15:55 +0300
commit544c39d1e72759d228bce4c5af72744db698d570 (patch)
tree6411e768e18bce93bb81ad1ca5296cc611b79951
parent7e731bbce221c423340821f1801a4fe021138358 (diff)
Fix editor infinit loop in search_prev
Fixes godotengine#31328
-rw-r--r--editor/code_editor.cpp14
-rw-r--r--scene/gui/text_edit.cpp3
2 files changed, 9 insertions, 8 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 606b619cac..b6cd69c3cd 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -366,14 +366,12 @@ bool FindReplaceBar::search_prev() {
if (text_edit->is_selection_active())
col--; // Skip currently selected word.
- if (line == result_line && col == result_col) {
- col -= text.length();
- if (col < 0) {
- line -= 1;
- if (line < 0)
- line = text_edit->get_line_count() - 1;
- col = text_edit->get_line(line).length();
- }
+ col -= text.length();
+ if (col < 0) {
+ line -= 1;
+ if (line < 0)
+ line = text_edit->get_line_count() - 1;
+ col = text_edit->get_line(line).length();
}
return _search(flags, line, col);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 736e546ed8..0464cc1ac8 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -5365,6 +5365,9 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l
break;
}
pos_from = last_pos - p_key.length();
+ if (pos_from < 0) {
+ break;
+ }
}
} else {
while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) {