Fix previous search for built-in-docs
This commit is contained in:
parent
f102ba8b2f
commit
7408b33895
2 changed files with 11 additions and 4 deletions
|
@ -1737,7 +1737,7 @@ void FindBar::_update_results_count() {
|
|||
int from_pos = 0;
|
||||
|
||||
while (true) {
|
||||
int pos = full_text.find(searched, from_pos);
|
||||
int pos = full_text.findn(searched, from_pos);
|
||||
if (pos == -1) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2460,13 +2460,19 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
|
|||
|
||||
if (p_from_selection && selection.active) {
|
||||
it = selection.to;
|
||||
charidx = selection.to_char + 1;
|
||||
charidx = p_search_previous ? selection.from_char - 1 : selection.to_char + 1;
|
||||
}
|
||||
|
||||
if (charidx == -1) {
|
||||
// At beginning of line and searching backwards
|
||||
it = _get_prev_item(it, true);
|
||||
}
|
||||
|
||||
while (it) {
|
||||
if (it->type == ITEM_TEXT) {
|
||||
ItemText *t = static_cast<ItemText *>(it);
|
||||
int sp = t->text.findn(p_string, charidx);
|
||||
int sp = p_search_previous ? t->text.rfindn(p_string, charidx) : t->text.findn(p_string, charidx);
|
||||
|
||||
if (sp != -1) {
|
||||
selection.from = it;
|
||||
selection.from_char = sp;
|
||||
|
@ -2501,10 +2507,11 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
|
|||
|
||||
if (p_search_previous) {
|
||||
it = _get_prev_item(it, true);
|
||||
charidx = -1;
|
||||
} else {
|
||||
it = _get_next_item(it, true);
|
||||
charidx = 0;
|
||||
}
|
||||
charidx = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue