diff --git a/src/haz3lschool/Exercise.re b/src/haz3lschool/Exercise.re index e96bebdec..c0b2684f5 100644 --- a/src/haz3lschool/Exercise.re +++ b/src/haz3lschool/Exercise.re @@ -147,7 +147,7 @@ module F = (ExerciseEnv: ExerciseEnv) => { // how these fields are saved and loaded to and from local memory // respectively. // NOTE: It may be helpful to look at changes made in the mutant-add-delete and title-editor - // branches in the Hazel repo to see and understand where changes + // branches in the Hazel repository to see and understand where changes // were made. It is likely that new implementations of editble features // will follow a similar route. }; diff --git a/src/haz3lweb/Main.re b/src/haz3lweb/Main.re index af8058b77..51e1db527 100644 --- a/src/haz3lweb/Main.re +++ b/src/haz3lweb/Main.re @@ -21,35 +21,49 @@ let restart_caret_animation = () => let apply = (model, action, ~schedule_action): Model.t => { restart_caret_animation(); - if (UpdateAction.is_edit(action)) { - last_edit_action := JsUtil.timestamp(); - edit_action_applied := true; - }; - if (Update.should_scroll_to_caret(action)) { - scroll_to_caret := true; - }; - last_edit_action := JsUtil.timestamp(); - switch ( - try({ - let new_model = Update.apply(model, action, ~schedule_action); - Log.update(action); - new_model; - }) { - | exc => + + let get_settings = (model: Model.t): Settings.t => model.settings; + + switch (action, get_settings(model).editing_title) { + | (UpdateAction.PerformAction(Insert(_)), true) => model + | (UpdateAction.PerformAction(Destruct(_)), true) => model + | (action, _) => + if (UpdateAction.is_edit(action)) { + last_edit_action := JsUtil.timestamp(); + edit_action_applied := true; + }; + let old_scroll = scroll_to_caret.contents; + if (Update.should_scroll_to_caret(action)) { + scroll_to_caret := true; Printf.printf( - "ERROR: Exception during apply: %s\n", - Printexc.to_string(exc), + "DEBUG: Scroll set to true for action: %s (was: %b)\n", + UpdateAction.show(action), + old_scroll, ); - Error(Exception(Printexc.to_string(exc))); - } - ) { - | Ok(model) => model - | Error(FailedToPerform(err)) => - print_endline(Update.Failure.show(FailedToPerform(err))); - model; - | Error(err) => - print_endline(Update.Failure.show(err)); - model; + }; + last_edit_action := JsUtil.timestamp(); + switch ( + try({ + let new_model = Update.apply(model, action, ~schedule_action); + Log.update(action); + new_model; + }) { + | exc => + Printf.printf( + "ERROR: Exception during apply: %s\n", + Printexc.to_string(exc), + ); + Error(Exception(Printexc.to_string(exc))); + } + ) { + | Ok(model) => model + | Error(FailedToPerform(err)) => + print_endline(Update.Failure.show(FailedToPerform(err))); + model; + | Error(err) => + print_endline(Update.Failure.show(err)); + model; + }; }; }; diff --git a/src/haz3lweb/Main.rei b/src/haz3lweb/Main.rei new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/haz3lweb/Main.rei @@ -0,0 +1 @@ + diff --git a/src/haz3lweb/UpdateAction.re b/src/haz3lweb/UpdateAction.re index 05c5ee715..9028b97f3 100644 --- a/src/haz3lweb/UpdateAction.re +++ b/src/haz3lweb/UpdateAction.re @@ -224,6 +224,7 @@ let should_scroll_to_caret = fun | Set(s_action) => switch (s_action) { + | EditingTitle => false | Mode(_) => true | Captions | SecondaryIcons @@ -235,7 +236,6 @@ let should_scroll_to_caret = | Benchmark | ContextInspector | InstructorMode - | EditingTitle | Evaluation(_) => false } | SetMeta(meta_action) => @@ -248,8 +248,6 @@ let should_scroll_to_caret = | UpdateResult(_) | ToggleStepper(_) | UpdateTitle(_) - | AddBuggyImplementation - | DeleteBuggyImplementation(_) | StepperAction(_, StepBackward | StepForward(_)) => false | FinishImportScratchpad(_) | FinishImportAll(_) @@ -261,6 +259,8 @@ let should_scroll_to_caret = | Undo | Redo | TAB + | AddBuggyImplementation + | DeleteBuggyImplementation(_) | Startup => true | PerformAction(a) => switch (a) { diff --git a/src/haz3lweb/view/Page.re b/src/haz3lweb/view/Page.re index 66ed0ea58..f354172ef 100644 --- a/src/haz3lweb/view/Page.re +++ b/src/haz3lweb/view/Page.re @@ -25,7 +25,7 @@ let key_handler = | None => Ignore | Some(action) => get_settings(model).editing_title - ? Many([inject(action)]) + ? Many([Stop_propagation, inject(action)]) : Many([Prevent_default, Stop_propagation, inject(action)]) } }; @@ -100,9 +100,7 @@ let main_view = ~inject: UpdateAction.t => Ui_effect.t(unit), {settings, editors, explainThisModel, results, ui_state, _}: Model.t, ) => { - print_endline("here, at main view, getting editor"); let editor = Editors.get_editor(editors); - print_endline("got editor!"); let cursor_info = Indicated.ci_of(editor.state.zipper, editor.state.meta.statics.info_map); let highlights =