summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/EditorUndoRedoManager.xml3
-rw-r--r--editor/debugger/editor_debugger_node.cpp2
-rw-r--r--editor/editor_undo_redo_manager.cpp40
-rw-r--r--editor/editor_undo_redo_manager.h1
4 files changed, 43 insertions, 3 deletions
diff --git a/doc/classes/EditorUndoRedoManager.xml b/doc/classes/EditorUndoRedoManager.xml
index 133ee9db0d..cd96e740e8 100644
--- a/doc/classes/EditorUndoRedoManager.xml
+++ b/doc/classes/EditorUndoRedoManager.xml
@@ -123,6 +123,9 @@
<constant name="GLOBAL_HISTORY" value="0" enum="SpecialHistory">
Global history not associated with any scene, but with external resources etc.
</constant>
+ <constant name="REMOTE_HISTORY" value="-9" enum="SpecialHistory">
+ History associated with remote inspector. Used when live editing a running project.
+ </constant>
<constant name="INVALID_HISTORY" value="-99" enum="SpecialHistory">
Invalid "null" history. It's a special value, not associated with any object.
</constant>
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 610f467faa..0a0f0cf90a 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -36,6 +36,7 @@
#include "editor/editor_log.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "editor/editor_undo_redo_manager.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/editor_debugger_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
@@ -274,6 +275,7 @@ void EditorDebuggerNode::stop(bool p_force) {
});
_break_state_changed();
breakpoints.clear();
+ EditorNode::get_undo_redo()->clear_history(false, EditorUndoRedoManager::REMOTE_HISTORY);
set_process(false);
}
diff --git a/editor/editor_undo_redo_manager.cpp b/editor/editor_undo_redo_manager.cpp
index 4bfa9b686c..ab33b2d051 100644
--- a/editor/editor_undo_redo_manager.cpp
+++ b/editor/editor_undo_redo_manager.cpp
@@ -33,6 +33,7 @@
#include "core/io/resource.h"
#include "core/os/os.h"
#include "core/templates/local_vector.h"
+#include "editor/debugger/editor_debugger_inspector.h"
#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
@@ -59,6 +60,10 @@ UndoRedo *EditorUndoRedoManager::get_history_undo_redo(int p_idx) const {
int EditorUndoRedoManager::get_history_id_for_object(Object *p_object) const {
int history_id = INVALID_HISTORY;
+ if (Object::cast_to<EditorDebuggerRemoteObject>(p_object)) {
+ return REMOTE_HISTORY;
+ }
+
if (Node *node = Object::cast_to<Node>(p_object)) {
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
@@ -278,6 +283,14 @@ bool EditorUndoRedoManager::undo() {
}
{
+ History &history = get_or_create_history(REMOTE_HISTORY);
+ if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
+ selected_history = history.id;
+ global_timestamp = history.undo_stack.back()->get().timestamp;
+ }
+ }
+
+ {
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
selected_history = history.id;
@@ -323,6 +336,14 @@ bool EditorUndoRedoManager::redo() {
}
{
+ History &history = get_or_create_history(REMOTE_HISTORY);
+ if (!history.redo_stack.is_empty() && history.redo_stack.back()->get().timestamp < global_timestamp) {
+ selected_history = history.id;
+ global_timestamp = history.redo_stack.back()->get().timestamp;
+ }
+ }
+
+ {
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
if (!history.redo_stack.is_empty() && history.redo_stack.back()->get().timestamp < global_timestamp) {
selected_history = history.id;
@@ -367,7 +388,7 @@ bool EditorUndoRedoManager::is_history_unsaved(int p_id) {
bool EditorUndoRedoManager::has_undo() {
for (const KeyValue<int, History> &E : history_map) {
- if ((E.key == GLOBAL_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.undo_stack.is_empty()) {
+ if ((E.key == GLOBAL_HISTORY || E.key == REMOTE_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.undo_stack.is_empty()) {
return true;
}
}
@@ -376,7 +397,7 @@ bool EditorUndoRedoManager::has_undo() {
bool EditorUndoRedoManager::has_redo() {
for (const KeyValue<int, History> &E : history_map) {
- if ((E.key == GLOBAL_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.redo_stack.is_empty()) {
+ if ((E.key == GLOBAL_HISTORY || E.key == REMOTE_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.redo_stack.is_empty()) {
return true;
}
}
@@ -385,7 +406,11 @@ bool EditorUndoRedoManager::has_redo() {
void EditorUndoRedoManager::clear_history(bool p_increase_version, int p_idx) {
if (p_idx != INVALID_HISTORY) {
- get_or_create_history(p_idx).undo_redo->clear_history(p_increase_version);
+ History &history = get_or_create_history(p_idx);
+ history.undo_redo->clear_history(p_increase_version);
+ history.undo_stack.clear();
+ history.redo_stack.clear();
+
if (!p_increase_version) {
set_history_as_saved(p_idx);
}
@@ -415,6 +440,14 @@ String EditorUndoRedoManager::get_current_action_name() {
}
{
+ History &history = get_or_create_history(REMOTE_HISTORY);
+ if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
+ selected_history = &history;
+ global_timestamp = history.undo_stack.back()->get().timestamp;
+ }
+ }
+
+ {
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
selected_history = &history;
@@ -477,6 +510,7 @@ void EditorUndoRedoManager::_bind_methods() {
ADD_SIGNAL(MethodInfo("version_changed"));
BIND_ENUM_CONSTANT(GLOBAL_HISTORY);
+ BIND_ENUM_CONSTANT(REMOTE_HISTORY);
BIND_ENUM_CONSTANT(INVALID_HISTORY);
}
diff --git a/editor/editor_undo_redo_manager.h b/editor/editor_undo_redo_manager.h
index 60bcd059df..08482b6e2d 100644
--- a/editor/editor_undo_redo_manager.h
+++ b/editor/editor_undo_redo_manager.h
@@ -41,6 +41,7 @@ class EditorUndoRedoManager : public RefCounted {
public:
enum SpecialHistory {
GLOBAL_HISTORY = 0,
+ REMOTE_HISTORY = -9,
INVALID_HISTORY = -99,
};