diff options
author | kobewi <kobewi4e@gmail.com> | 2022-10-22 23:54:37 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2024-04-25 23:22:47 +0200 |
commit | 3a1246c198ac819edaf0d3f0c52f2255af0c8977 (patch) | |
tree | 2e6ef587fd2743dad8176881e4454aa9f40b3468 /editor/code_editor.cpp | |
parent | 11d3768132582d192b8464769f26b493ae822321 (diff) | |
download | redot-engine-3a1246c198ac819edaf0d3f0c52f2255af0c8977.tar.gz |
Store line change in script navigation history
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r-- | editor/code_editor.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 779080786a..49896d66d8 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -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() { |