From 0702e601bee6a7a163a37aed53e5fa184c5115f7 Mon Sep 17 00:00:00 2001
From: Matt Keenan <negabinary@gmail.com>
Date: Wed, 13 Nov 2024 16:04:07 -0500
Subject: [PATCH] thunk printing

---
 src/haz3lweb/app/Cursor.re                       | 2 +-
 src/haz3lweb/app/Page.re                         | 8 ++++++--
 src/haz3lweb/app/editors/code/CodeWithStatics.re | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/haz3lweb/app/Cursor.re b/src/haz3lweb/app/Cursor.re
index 4d3f9d602f..f5a483c60e 100644
--- a/src/haz3lweb/app/Cursor.re
+++ b/src/haz3lweb/app/Cursor.re
@@ -1,6 +1,6 @@
 type cursor('update) = {
   info: option(Haz3lcore.Info.t),
-  selected_text: option(string),
+  selected_text: option(unit => string),
   editor: option(Haz3lcore.Editor.t),
   editor_action: Haz3lcore.Action.t => option('update),
   undo_action: option('update),
diff --git a/src/haz3lweb/app/Page.re b/src/haz3lweb/app/Page.re
index d709d39711..cb2ceb5f45 100644
--- a/src/haz3lweb/app/Page.re
+++ b/src/haz3lweb/app/Page.re
@@ -333,11 +333,15 @@ module View = {
         Effect.Ignore;
       }),
       Attr.on_copy(_ => {
-        JsUtil.copy(cursor.selected_text |> Option.value(~default=""));
+        JsUtil.copy(
+          (cursor.selected_text |> Option.value(~default=() => ""))(),
+        );
         Effect.Ignore;
       }),
       Attr.on_cut(_ => {
-        JsUtil.copy(cursor.selected_text |> Option.value(~default=""));
+        JsUtil.copy(
+          (cursor.selected_text |> Option.value(~default=() => ""))(),
+        );
         Option.map(
           inject,
           Selection.handle_key_event(
diff --git a/src/haz3lweb/app/editors/code/CodeWithStatics.re b/src/haz3lweb/app/editors/code/CodeWithStatics.re
index 1951ce1742..b183e3c861 100644
--- a/src/haz3lweb/app/editors/code/CodeWithStatics.re
+++ b/src/haz3lweb/app/editors/code/CodeWithStatics.re
@@ -31,7 +31,7 @@ module Model = {
   let get_cursor_info = (model: t): Cursor.cursor(Action.t) => {
     info: Indicated.ci_of(model.editor.state.zipper, model.statics.info_map),
     selected_text:
-      Some(Printer.to_string_selection(model.editor.state.zipper)),
+      Some(() => Printer.to_string_selection(model.editor.state.zipper)),
     editor: Some(model.editor),
     editor_action: x => Some(x),
     undo_action: None,