@@ -21,6 +21,8 @@ type t =
2121 dependencies : string list ;
2222 }
2323
24+ (* XXX: a change to this type may require another change in editor_lib.ml *)
25+
2426let encoding =
2527 let open Json_encoding in
2628 conv
@@ -192,7 +194,7 @@ module File = struct
192194
193195 let depend =
194196 { key = " depend.txt" ; ciphered = false ;
195- decode = (fun v -> Some v) ;
197+ decode = (fun v -> Some v) ; (* XXX should this produce None sometimes? *)
196198 encode = (function
197199 | None -> " " (* no `depend` ~ empty `depend` *)
198200 | Some txt -> txt) ;
@@ -289,7 +291,7 @@ module File = struct
289291 * return ()
290292 * with _ -> return ()
291293 * in *)
292- let descrs = ref [] in
294+ let descrs : (string option * string) list ref = ref [] in
293295 let rec read_descr lang = function
294296 | [] ->
295297 (* If there are no extensions to try, we just give up. *)
@@ -314,23 +316,32 @@ module File = struct
314316 | Some raw ->
315317 (* If it does, we apply the function, add the
316318 description to [!descrs] and return. *)
317- descrs := (lang, f raw) :: ! descrs;
319+ descrs := (lang, f raw) :: ! descrs ;
318320 return ()
319321 in
320322 let markdown_to_html md =
321323 Omd. (md |> of_string |> to_html)
322324 in
323325 let read_descrs () =
324326 let langs = [] in
327+ (* XXX: Really [] ? *)
325328 let exts = [
326329 (Filename. extension descr.key, fun h -> h) ;
327330 (" .md" , markdown_to_html)
328331 ] in
329332 join (read_descr None exts :: List. map (fun l -> read_descr (Some l) exts) langs)
330333 >> = fun () ->
331- ex := set descr
332- (List. map (function (None , v ) -> " " , v | (Some l , v ) -> l, v) ! descrs)
333- ! ex;
334+ let res = (List. map (function (None , v ) -> " " , v | (Some l , v ) -> l, v) ! descrs) in
335+ (* let res' = descr.encode res in
336+ let stack_overflow = descr.decode res' in () *)
337+
338+ (* Also reproducible with:
339+ let html = (* markdown_to_html md (* length = 13711 *) *)
340+ String.init 14000 (fun n -> if n mod 2 = 0 then 'A' else ' ') in
341+ let res' = descrs_to_string [("", html)] (* length = 13857 *) in
342+ let stack_overflow = descrs_from_string res' in () *)
343+
344+ ex := set descr res ! ex;
334345 return ()
335346 in
336347 join
0 commit comments