Skip to content

Commit

Permalink
QoL: reset the toplevel every time before evaluating code from the ed…
Browse files Browse the repository at this point in the history
…itor (#411)

You might lose what you manually typed directly in the toplevel pane, but that
shouldn't be a problem, and most importantly it will avoid already defined ids
to clutter the environment.

These often cause student confusion with cases like "type t instead of t", or a
missing `rec` keyword that compiles because using an older definition.
  • Loading branch information
AltGr committed Sep 1, 2021
1 parent f7bf420 commit 65ce0c4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/app/learnocaml_common.ml
Expand Up @@ -894,6 +894,7 @@ module Editor_button (E : Editor_info) = struct
let eval top select_tab =
editor_button
~icon: "run" [%i"Eval code"] @@ fun () ->
Learnocaml_toplevel.reset top >>= fun () ->
Learnocaml_toplevel.execute_phrase top (Ace.get_contents E.ace) >>= fun _ ->
select_tab "toplevel";
Lwt.return_unit
Expand Down

0 comments on commit 65ce0c4

Please sign in to comment.