summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-10-09 15:19:15 +0200
committerGitHub <noreply@github.com>2017-10-09 15:19:15 +0200
commit438e32d6520c4fc37676bfdc2d287178a13c326c (patch)
treefbaacfbc2dc3361ca7f11ec2f7358c6255329594
parentcb7e4aa6d46ec247c7fc41104e4459a062cce77c (diff)
parentb07dfd75eaa3a89aefda9c26e33f91d8eaa80fc8 (diff)
Merge pull request #11941 from Paulb23/members_selected_scroll_issue_11648
Consistant scroll when using members overview, issue 11648
-rw-r--r--editor/plugins/script_editor_plugin.cpp6
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--scene/gui/text_edit.cpp8
3 files changed, 14 insertions, 2 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 5e66488afb..477d440f28 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1278,7 +1278,11 @@ void ScriptEditor::_members_overview_selected(int p_idx) {
if (!se) {
return;
}
- se->goto_line(members_overview->get_item_metadata(p_idx));
+ Dictionary state;
+ state["scroll_position"] = members_overview->get_item_metadata(p_idx);
+ state["column"] = 0;
+ state["row"] = members_overview->get_item_metadata(p_idx);
+ se->set_edit_state(state);
se->ensure_focus();
}
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index a24856dad7..adf65c11e1 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -529,9 +529,9 @@ void ScriptTextEditor::ensure_focus() {
void ScriptTextEditor::set_edit_state(const Variant &p_state) {
Dictionary state = p_state;
- code_editor->get_text_edit()->set_v_scroll(state["scroll_position"]);
code_editor->get_text_edit()->cursor_set_column(state["column"]);
code_editor->get_text_edit()->cursor_set_line(state["row"]);
+ code_editor->get_text_edit()->set_v_scroll(state["scroll_position"]);
code_editor->get_text_edit()->grab_focus();
//int scroll_pos;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index d14d3ef947..33c29547be 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4287,6 +4287,14 @@ int TextEdit::get_v_scroll() const {
}
void TextEdit::set_v_scroll(int p_scroll) {
+ if (p_scroll < 0) {
+ p_scroll = 0;
+ }
+ if (!scroll_past_end_of_file_enabled) {
+ if (p_scroll + get_visible_rows() > get_line_count()) {
+ p_scroll = get_line_count() - get_visible_rows();
+ }
+ }
v_scroll->set_value(p_scroll);
cursor.line_ofs = p_scroll;
}