@@ -42,10 +42,8 @@ func batch_execute(params: Dictionary) -> Dictionary:
4242 var succeeded := 0
4343 var stopped_at = null
4444 var all_undoable := true
45- var failure_error : Dictionary = {}
46- # UndoRedo references captured after the first successful commit to each
47- # history. We can't call get_history_undo_redo() before a commit exists
48- # because Godot errors on an empty history_map.
45+ # Captured after the first successful commit — get_history_undo_redo()
46+ # errors if called before any action exists in the history_map.
4947 var histories : Array = []
5048
5149 for idx in range (commands .size ()):
@@ -61,7 +59,6 @@ func batch_execute(params: Dictionary) -> Dictionary:
6159 result_entry ["error" ] = raw_result .get ("error" , {})
6260 results .append (result_entry )
6361 stopped_at = idx
64- failure_error = raw_result .get ("error" , {})
6562 break
6663 else :
6764 var data : Dictionary = raw_result .get ("data" , raw_result )
@@ -85,7 +82,7 @@ func batch_execute(params: Dictionary) -> Dictionary:
8582 "undoable" : stopped_at == null and all_undoable and not rolled_back ,
8683 }
8784 if stopped_at != null :
88- response_data ["error" ] = failure_error
85+ response_data ["error" ] = results [ - 1 ][ "error" ]
8986 return {"data" : response_data }
9087
9188
@@ -94,12 +91,12 @@ func batch_execute(params: Dictionary) -> Dictionary:
9491## least one action has been committed to each history.
9592func _capture_histories (histories : Array ) -> void :
9693 var scene_root := EditorInterface .get_edited_scene_root ()
97- if scene_root ! = null :
98- var scene_id := _undo_redo . get_object_history_id ( scene_root )
99- if scene_id != EditorUndoRedoManager . INVALID_HISTORY :
100- var scene_ur := _undo_redo .get_history_undo_redo (scene_id )
101- if scene_ur != null and not scene_ur in histories :
102- histories .append (scene_ur )
94+ if scene_root = = null :
95+ return
96+ var scene_id := _undo_redo . get_object_history_id ( scene_root )
97+ var scene_ur := _undo_redo .get_history_undo_redo (scene_id )
98+ if scene_ur != null and not scene_ur in histories :
99+ histories .append (scene_ur )
103100
104101
105102## Undo `count` actions by calling undo() on captured histories in LIFO order.
0 commit comments