Fix EditorUndoRedoManager's handling of MERGE_ENDS
This commit is contained in:
parent
ad9302bafc
commit
38c50b4ed3
|
@ -248,12 +248,32 @@ void EditorUndoRedoManager::commit_action(bool p_execute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!history.undo_stack.is_empty()) {
|
if (!history.undo_stack.is_empty()) {
|
||||||
const Action &prev_action = history.undo_stack.back()->get();
|
// Discard action if it should be merged (UndoRedo handles merging internally).
|
||||||
if (pending_action.merge_mode != UndoRedo::MERGE_DISABLE && pending_action.merge_mode == prev_action.merge_mode && pending_action.action_name == prev_action.action_name) {
|
switch (pending_action.merge_mode) {
|
||||||
// Discard action if it should be merged (UndoRedo handles merging internally).
|
case UndoRedo::MERGE_DISABLE:
|
||||||
pending_action = Action();
|
break; // Nothing to do here.
|
||||||
is_committing = false;
|
case UndoRedo::MERGE_ENDS: {
|
||||||
return;
|
if (history.undo_stack.size() < 2) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Action &prev_action = history.undo_stack.back()->get();
|
||||||
|
const Action &pre_prev_action = history.undo_stack.back()->prev()->get();
|
||||||
|
if (pending_action.merge_mode == prev_action.merge_mode && pending_action.merge_mode == pre_prev_action.merge_mode &&
|
||||||
|
pending_action.action_name == prev_action.action_name && pending_action.action_name == pre_prev_action.action_name) {
|
||||||
|
pending_action = Action();
|
||||||
|
is_committing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case UndoRedo::MERGE_ALL: {
|
||||||
|
const Action &prev_action = history.undo_stack.back()->get();
|
||||||
|
if (pending_action.merge_mode == prev_action.merge_mode && pending_action.action_name == prev_action.action_name) {
|
||||||
|
pending_action = Action();
|
||||||
|
is_committing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue