Skip to content

Commit 5e0959b

Browse files
committed
Use "automatic" undo when no undo is provided by script execution
1 parent 13d0abc commit 5e0959b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/engine/step/actions.ml

+9-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ module AttributeActions = struct
8989
Brr.Console.(log [ body ]);
9090
let args = Jv.Function.[ ("slip", Fun.id) ] in
9191
let f = Jv.Function.v ~body ~args in
92+
let undos_ref = ref [] in
9293
let arg =
9394
Jv.obj
9495
[|
@@ -106,12 +107,19 @@ module AttributeActions = struct
106107
| None -> Brr.El.remove_inline_style style elem
107108
| Some old_value -> Brr.El.set_inline_style style old_value elem
108109
in
110+
undos_ref := undo :: !undos_ref;
109111
Jv.callback ~arity:1 undo );
110112
|]
111113
in
112114
let u = f arg in
113115
let undo () =
114-
Fut.return @@ try ignore @@ Jv.call u "undo" [||] with _ -> ()
116+
try Fut.return (ignore @@ Jv.call u "undo" [||])
117+
with _ ->
118+
List.fold_left
119+
(fun acc f ->
120+
let* () = acc in
121+
f ())
122+
(Fut.return ()) !undos_ref
115123
in
116124
Undoable.return ~undo ()
117125
in

0 commit comments

Comments
 (0)