Merge pull request #31892 from alexey-makarenko/fix/editor_search_back_infinitely

Fix editor infinite loop in search_prev issue #31328
This commit is contained in:
Rémi Verschelde 2019-09-02 18:30:20 +02:00 committed by GitHub
commit aa0ed47122
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View file

@ -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);

View file

@ -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) {