diff --git a/lib/pretty.ml b/lib/pretty.ml index d15fcf9c..2b896525 100644 --- a/lib/pretty.ml +++ b/lib/pretty.ml @@ -54,6 +54,22 @@ let is_atom (x: [> t]) = let is_atom_list l = List.for_all is_atom l +(* + inside_box: indicates that we're already within a box that imposes + a certain style and we shouldn't create a new one. This is used for + printing field values like this: + + foo: [ + bar + ] + + rather than something else like + + foo: + [ + bar + ] +*) let rec format ~inside_box std (out:Format.formatter) (x:t) : unit = match x with | `Null -> Format.pp_print_string out "null" @@ -83,7 +99,7 @@ let rec format ~inside_box std (out:Format.formatter) (x:t) : unit = #endif | `List [] -> Format.pp_print_string out "[]" | `List l -> - if not inside_box then Format.fprintf out "@["; + if not inside_box then Format.fprintf out "@["; if is_atom_list l then (* use line wrapping like we would do for a paragraph of text *) Format.fprintf out "[@;<1 0>@[%a@]@;<1 -2>]" diff --git a/test/pretty/atd.expected.json b/test/pretty/atd.expected.json index 2be9c2e3..edde4076 100644 --- a/test/pretty/atd.expected.json +++ b/test/pretty/atd.expected.json @@ -27,7 +27,8 @@ [ "V3", "testing" ], [ "V44", 255 ], [ "V5", "None" ], - [ "V5", [ "Some", true ] ] ], + [ "V5", [ "Some", true ] ] + ], { "v2": "A" }, { "v2": [ "B", 100 ] }, [ "C1", [ "C2", true ], [ "C2", false ] ],