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

Store line change in script navigation history

This commit is contained in:
kobewi
2022-10-22 23:54:37 +02:00
parent 11d3768132
commit 3a1246c198
8 changed files with 107 additions and 9 deletions

View File

@@ -1613,13 +1613,26 @@ Variant CodeTextEditor::get_edit_state() {
return state;
}
Variant CodeTextEditor::get_previous_state() {
return previous_state;
}
void CodeTextEditor::store_previous_state() {
previous_state = get_navigation_state();
}
void CodeTextEditor::set_edit_state(const Variant &p_state) {
Dictionary state = p_state;
/* update the row first as it sets the column to 0 */
text_editor->set_caret_line(state["row"]);
text_editor->set_caret_column(state["column"]);
text_editor->set_v_scroll(state["scroll_position"]);
if (int(state["scroll_position"]) == -1) {
// Special case for previous state.
text_editor->center_viewport_to_caret();
} else {
text_editor->set_v_scroll(state["scroll_position"]);
}
text_editor->set_h_scroll(state["h_scroll_position"]);
if (state.get("selection", false)) {
@@ -1648,6 +1661,10 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
text_editor->set_line_as_bookmarked(bookmarks[i], true);
}
}
if (previous_state.is_empty()) {
previous_state = p_state;
}
}
Variant CodeTextEditor::get_navigation_state() {