Skip to content

Commit 615d911

Browse files
committed
Refactor command executions to use the same terminal instance for consistency
1 parent fe8bf76 commit 615d911

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/extension_commands.ml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,21 @@ let _switch_impl_intf =
247247
command Command_api.Internal.switch_impl_intf callback
248248
;;
249249

250+
let walkthrough_terminal_instance = ref None
251+
252+
let walkthrough_terminal instance =
253+
match !walkthrough_terminal_instance with
254+
| Some t -> t
255+
| None ->
256+
let t =
257+
Terminal_sandbox.create
258+
~name:"OCaml Platform Walkthrough"
259+
(Extension_instance.sandbox instance)
260+
in
261+
walkthrough_terminal_instance := Some t;
262+
t
263+
;;
264+
250265
let _install_opam =
251266
let callback (instance : Extension_instance.t) () =
252267
let process_installation () =
@@ -277,9 +292,7 @@ let _install_opam =
277292
let open Promise.Result.Syntax in
278293
let+ _ =
279294
let _ =
280-
let terminal =
281-
Extension_instance.sandbox instance |> Terminal_sandbox.create
282-
in
295+
let terminal = walkthrough_terminal instance in
283296
let _ = Terminal_sandbox.show ~preserveFocus:true terminal in
284297
Terminal_sandbox.send
285298
terminal
@@ -320,9 +333,7 @@ let _init_opam =
320333
let open Promise.Result.Syntax in
321334
let+ _ =
322335
let _ =
323-
let terminal =
324-
Extension_instance.sandbox instance |> Terminal_sandbox.create
325-
in
336+
let terminal = walkthrough_terminal instance in
326337
let _ = Terminal_sandbox.show ~preserveFocus:true terminal in
327338
Terminal_sandbox.send terminal "opam init"
328339
in
@@ -357,9 +368,7 @@ let _install_ocaml_dev =
357368
let open Promise.Result.Syntax in
358369
let+ _ =
359370
let _ =
360-
let terminal =
361-
Extension_instance.sandbox instance |> Terminal_sandbox.create
362-
in
371+
let terminal = walkthrough_terminal instance in
363372
let _ = Terminal_sandbox.show ~preserveFocus:true terminal in
364373
Terminal_sandbox.send
365374
terminal
@@ -396,9 +405,7 @@ let _open_utop =
396405
let open Promise.Result.Syntax in
397406
let+ _ =
398407
let _ =
399-
let terminal =
400-
Extension_instance.sandbox instance |> Terminal_sandbox.create
401-
in
408+
let terminal = walkthrough_terminal instance in
402409
let _ = Terminal_sandbox.show ~preserveFocus:true terminal in
403410
Terminal_sandbox.send terminal "opam exec -- utop"
404411
in

0 commit comments

Comments
 (0)