summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorGuilherme Felipe <guilhermefelipecgs@gmail.com>2015-05-13 23:19:15 -0300
committerGuilherme Felipe <guilhermefelipecgs@gmail.com>2015-05-13 23:35:00 -0300
commit53541c69d48444bf8a502b35dcd4370c30058fb6 (patch)
tree574716649ca221f36bf423ccd5c3f96ac852157c /scene
parent40c0e1993aa28f580b9bf597abc8902b5d5c1e93 (diff)
Fix for scroll_to_line and search functions, fix #1897
The function scroll_to_line(0) should return ERR_FAIL_INDEX because the first line is 1.
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/rich_text_label.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 6b2e5aea78..bf719e671a 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1486,10 +1486,10 @@ Error RichTextLabel::append_bbcode(const String& p_bbcode) {
void RichTextLabel::scroll_to_line(int p_line) {
+ p_line -= 1;
ERR_FAIL_INDEX(p_line,lines.size());
_validate_line_caches();
- vscroll->set_val(lines[p_line].height_accum_cache);
-
+ vscroll->set_val(lines[p_line].height_accum_cache-lines[p_line].height_cache);
}
@@ -1552,27 +1552,23 @@ bool RichTextLabel::search(const String& p_string,bool p_from_selection) {
it=_get_next_item(it);
}
- if (!it)
- line=lines.size()-1;
}
- scroll_to_line(line-2);
+ if (line > 1) {
+ line-=1;
+ }
+
+ scroll_to_line(line);
return true;
}
- } else if (it->type==ITEM_NEWLINE) {
-
- line=static_cast<ItemNewline*>(it)->line;
}
-
it=_get_next_item(it);
charidx=0;
}
-
-
return false;
}