From cd9ec95080bf69926d04edbc7be7e4c83a23ab2e Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Fri, 23 Jan 2026 15:32:30 +0000 Subject: [PATCH] Fix history --- src/lib/interactive.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/interactive.ml b/src/lib/interactive.ml index 5f58231..dc1fdb2 100644 --- a/src/lib/interactive.ml +++ b/src/lib/interactive.ml @@ -69,6 +69,11 @@ module Make (S : Types.State) (E : Types.Exec) = struct let h = ref [] + let add_history c = + let c = String.trim c in + let new_h = List.filter (fun s -> not (String.equal c s)) !h in + h := c :: new_h + let history prefix = if prefix <> "" then List.filter (fun s -> String.starts_with ~prefix s) !h else !h @@ -90,7 +95,7 @@ module Make (S : Types.State) (E : Types.Exec) = struct | String (Some c) -> let ast = Ast.of_string (String.trim c) in let ctx', _ast = Eval.run ctx ast in - h := c :: !h; + add_history c; loop ctx' | Ctrl_c -> let c = Exit.value ctx in -- 2.51.2