Merge pull request #115876 from kitbdev/fix-te-search-backwards
Fix TextEdit backwards search skipping matches
This commit is contained in:
commit
781ae8deb2
1 changed files with 5 additions and 0 deletions
|
|
@ -4895,6 +4895,11 @@ Point2i TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_fro
|
||||||
int current_line = p_from_line;
|
int current_line = p_from_line;
|
||||||
int current_column = p_from_column;
|
int current_column = p_from_column;
|
||||||
|
|
||||||
|
if (p_search_flags & SEARCH_BACKWARDS) {
|
||||||
|
// `rfind` requires the from index to be within the bounds of the last possible match position.
|
||||||
|
current_column = MIN(current_column, text[p_from_line].length() - p_key.length());
|
||||||
|
}
|
||||||
|
|
||||||
// + 1 because we'll search p_from_line twice - starting from p_from_column, and then again at the very end.
|
// + 1 because we'll search p_from_line twice - starting from p_from_column, and then again at the very end.
|
||||||
for (int i = 0; i < text.size() + 1; i++) {
|
for (int i = 0; i < text.size() + 1; i++) {
|
||||||
const String &text_line = text[current_line];
|
const String &text_line = text[current_line];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue