1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Center Script Editor when jumping to bookmarks/breakpoints

This commit is contained in:
Tomasz Chabora
2019-12-01 18:35:07 +01:00
parent ad95424dba
commit f4d0e598a7
2 changed files with 6 additions and 0 deletions

View File

@@ -1565,6 +1565,7 @@ void CodeTextEditor::goto_next_bookmark() {
if (bline > line) { if (bline > line) {
text_editor->unfold_line(bline); text_editor->unfold_line(bline);
text_editor->cursor_set_line(bline); text_editor->cursor_set_line(bline);
text_editor->center_viewport_to_cursor();
return; return;
} }
} }
@@ -1589,6 +1590,7 @@ void CodeTextEditor::goto_prev_bookmark() {
if (bline < line) { if (bline < line) {
text_editor->unfold_line(bline); text_editor->unfold_line(bline);
text_editor->cursor_set_line(bline); text_editor->cursor_set_line(bline);
text_editor->center_viewport_to_cursor();
return; return;
} }
} }

View File

@@ -707,6 +707,7 @@ void ScriptTextEditor::_bookmark_item_pressed(int p_idx) {
_edit_option(bookmarks_menu->get_item_id(p_idx)); _edit_option(bookmarks_menu->get_item_id(p_idx));
} else { } else {
code_editor->goto_line(bookmarks_menu->get_item_metadata(p_idx)); code_editor->goto_line(bookmarks_menu->get_item_metadata(p_idx));
code_editor->get_text_edit()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
} }
} }
@@ -856,6 +857,7 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) {
_edit_option(breakpoints_menu->get_item_id(p_idx)); _edit_option(breakpoints_menu->get_item_id(p_idx));
} else { } else {
code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx)); code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx));
code_editor->get_text_edit()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred().
} }
} }
@@ -1307,6 +1309,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (bline > line) { if (bline > line) {
tx->unfold_line(bline); tx->unfold_line(bline);
tx->cursor_set_line(bline); tx->cursor_set_line(bline);
tx->center_viewport_to_cursor();
return; return;
} }
} }
@@ -1332,6 +1335,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
if (bline < line) { if (bline < line) {
tx->unfold_line(bline); tx->unfold_line(bline);
tx->cursor_set_line(bline); tx->cursor_set_line(bline);
tx->center_viewport_to_cursor();
return; return;
} }
} }