Merge pull request #94002 from kitbdev/fix-goto-error

Fix goto line issues in code editor
This commit is contained in:
Rémi Verschelde 2024-08-27 22:27:25 +02:00
commit d35bee9cdd
No known key found for this signature in database
GPG key ID: C3336907360768E1
9 changed files with 38 additions and 45 deletions

View file

@ -493,7 +493,7 @@ void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) {
if (ScriptTextEditor *script_text_editor = Object::cast_to<ScriptTextEditor>(current)) {
script_text_editor->goto_line_centered(p_line);
} else if (current) {
current->goto_line(p_line, true);
current->goto_line(p_line);
}
_save_history();
@ -1857,17 +1857,13 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
}
void ScriptEditor::_members_overview_selected(int p_idx) {
ScriptEditorBase *se = _get_current_editor();
if (!se) {
return;
int line = members_overview->get_item_metadata(p_idx);
ScriptEditorBase *current = _get_current_editor();
if (ScriptTextEditor *script_text_editor = Object::cast_to<ScriptTextEditor>(current)) {
script_text_editor->goto_line_centered(line);
} else if (current) {
current->goto_line(line);
}
// Go to the member's line and reset the cursor column. We can't change scroll_position
// directly until we have gone to the line first, since code might be folded.
se->goto_line(members_overview->get_item_metadata(p_idx));
Dictionary state = se->get_edit_state();
state["column"] = 0;
state["scroll_position"] = members_overview->get_item_metadata(p_idx);
se->set_edit_state(state);
}
void ScriptEditor::_help_overview_selected(int p_idx) {