easy-format icon indicating copy to clipboard operation
easy-format copied to clipboard

Cannot seem to use to_formatter within custom

Open smondet opened this issue 6 years ago • 2 comments

I think it could be because of the call to flush https://github.com/mjambon/easy-format/blob/master/src/easy_format.ml#L620

What I'm trying to do looks like:

custom (fun ppf ->
   (* .. bunch of pp_stuff ... *)
   List.iter a_few_easy_format_dot_ts ~f:(fun ef ->
      (* ... *)
     Easy_format.Pretty.to_formatter ppf ef
      (* ... *)
   ) ;
  (* ... more pp_stuff ... *)
)

smondet avatar Feb 22 '19 13:02 smondet

What are you expectations and what error are you getting?

mjambon avatar Feb 22 '19 19:02 mjambon

In the example above, I am expecting ef to be properly indented and formatted, but after the first one, they seem to show up non-indented and breaking "boxes" (that's why I think it is because of the call to Format.pp_print_flush).

If I replace Easy_format.Pretty.to_formatter ppf ef with fprintf ppf "random stuff" the same code seems to be correctly formatting the output.

smondet avatar Feb 22 '19 20:02 smondet