fix symbol jump history navigation issue.

This commit is contained in:
jinyangcruise 2026-02-18 00:17:00 +08:00
parent 8a4df69e22
commit e4e31abeaa
13 changed files with 183 additions and 32 deletions

View file

@ -201,12 +201,6 @@ void ScriptEditor::_goto_script_line(Ref<RefCounted> p_script, int p_line) {
if (scr.is_valid() && (scr->has_source_code() || scr->get_path().is_resource_file())) {
if (edit(p_script, p_line, 0)) {
EditorNode::get_singleton()->push_item(p_script.ptr());
if (TextEditorBase *current = Object::cast_to<TextEditorBase>(_get_current_editor())) {
current->goto_line_centered(p_line);
}
_save_history();
}
}
}
@ -314,7 +308,9 @@ void ScriptEditor::_save_history() {
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<TextEditorBase>(n)) {
history.write[history_pos].state = Object::cast_to<TextEditorBase>(n)->get_navigation_state();
Dictionary nav_state = Object::cast_to<TextEditorBase>(n)->get_navigation_state();
nav_state["ensure_caret_visible"] = true;
history.write[history_pos].state = nav_state;
}
if (Object::cast_to<EditorHelp>(n)) {
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
@ -373,7 +369,9 @@ void ScriptEditor::_go_to_tab(int p_idx) {
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<TextEditorBase>(n)) {
history.write[history_pos].state = Object::cast_to<TextEditorBase>(n)->get_navigation_state();
Dictionary nav_state = Object::cast_to<TextEditorBase>(n)->get_navigation_state();
nav_state["ensure_caret_visible"] = true;
history.write[history_pos].state = nav_state;
}
if (Object::cast_to<EditorHelp>(n)) {
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
@ -2213,7 +2211,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
}
if (p_line >= 0) {
teb->goto_line(p_line, p_col);
teb->goto_line_centered(p_line, p_col);
}
} else if (tab_container->get_current_tab() != i) {
_go_to_tab(i);
@ -2340,7 +2338,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
if (TextEditorBase *teb = Object::cast_to<TextEditorBase>(seb)) {
if (p_line >= 0) {
teb->goto_line(p_line, p_col);
teb->goto_line_centered(p_line, p_col);
}
}
@ -3416,7 +3414,9 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
Node *n = tab_container->get_current_tab_control();
if (Object::cast_to<TextEditorBase>(n)) {
history.write[history_pos].state = Object::cast_to<TextEditorBase>(n)->get_navigation_state();
Dictionary nav_state = Object::cast_to<TextEditorBase>(n)->get_navigation_state();
nav_state["ensure_caret_visible"] = true;
history.write[history_pos].state = nav_state;
}
if (Object::cast_to<EditorHelp>(n)) {
history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();