Skip to content

Commit

Permalink
Pp_format: remember to flush (important for multifile)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Jan 23, 2024
1 parent 6b1f456 commit 156525d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion minidebug_runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ module Pp_format (Log_to : Debug_ch) : Debug_runtime = struct
| [] -> failwith "ppx_minidebug: close_log must follow an earlier open_log_preamble"
| _ :: tl -> stack := tl);
CFormat.pp_close_box !ppf ();
if List.is_empty !stack && refresh_ch () then ppf := get_ppf ()
if List.is_empty !stack then (
(* Importantly, pp_print_newline invokes pp_print_flush, flushes the out channel. *)
CFormat.pp_print_newline !ppf ();
if refresh_ch () then ppf := get_ppf ())

let open_log_preamble_brief ~fname ~pos_lnum ~pos_colnum ~message ~entry_id:_ =
stack := 0 :: !stack;
Expand Down
2 changes: 1 addition & 1 deletion test/debugger_pp_format.expected.log
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ depth = 0 x = { Test_debug_pp.first = 7; second = 42 } "test/test_debug_pp.ml"
"test/test_debug_pp.ml":19:22-25:9: loop
depth = 7 x = { Test_debug_pp.first = 18; second = 10 } loop = 28 loop = 28
loop = 28 loop = 28 z = 28 loop = 35 z = 35 loop = 42 z = 42 loop = 49
z = 49 loop = 56
z = 49 loop = 56

0 comments on commit 156525d

Please sign in to comment.