File tree Expand file tree Collapse file tree 5 files changed +11
-12
lines changed Expand file tree Collapse file tree 5 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -1521,9 +1521,7 @@ end = struct
1521
1521
(* String literals using the heavy syntax are not simple. *)
1522
1522
| Pexp_constant {pconst_desc = Pconst_string (_ , _ , Some _ ); _} -> false
1523
1523
(* Only strings fitting on the line are simple. *)
1524
- | Pexp_constant {pconst_desc = Pconst_string (_ , loc , None); _} ->
1525
- Exp. is_trivial exp
1526
- || (Location. height loc = 1 && fit_margin c (width xexp))
1524
+ | Pexp_constant {pconst_desc = Pconst_string (_ , _ , None); _} -> true
1527
1525
| Pexp_constant _ -> true
1528
1526
| Pexp_field _ | Pexp_ident _ | Pexp_send _
1529
1527
| Pexp_construct (_, None )
Original file line number Diff line number Diff line change @@ -303,8 +303,8 @@ let rec place t loc_tree ?prev_loc ?deep_loc locs cmts =
303
303
(* * Relocate comments, for Ast transformations such as sugaring. *)
304
304
let relocate (t : t ) ~src ~before ~after =
305
305
if t.debug then
306
- Format. eprintf " relocate %a to %a and %a@\n %!" Location. fmt src
307
- Location. fmt before Location. fmt after ;
306
+ Format. eprintf " relocate %a to %a and %a@\n %!"
307
+ Location. fmt src Location. fmt before Location. fmt after ;
308
308
let merge_and_sort x y =
309
309
List. rev_append x y
310
310
|> List. sort ~compare: (Comparable. lift Location. compare_start ~f: Cmt. loc)
Original file line number Diff line number Diff line change @@ -187,8 +187,8 @@ let rec pp_from fs = function
187
187
| `Profile (s , p ) -> Format. fprintf fs " (profile %s%a)" s pp_from_src p
188
188
| `Updated (x , None) -> pp_from_src fs x
189
189
| `Updated (x , Some r ) ->
190
- Format. fprintf fs " %a -- Warning (redundant): %a" pp_from_src x pp_from
191
- r
190
+ Format. fprintf fs " %a -- Warning (redundant): %a"
191
+ pp_from_src x pp_from r
192
192
193
193
let loc_udapted_from = function
194
194
| `Commandline -> Location. in_file " <command-line>"
Original file line number Diff line number Diff line change @@ -1520,13 +1520,14 @@ and fmt_args_grouped ?epi:(global_epi = noop) c ctx args =
1520
1520
let xexp = sub_exp ~ctx x in
1521
1521
is_simple c.conf (expression_width c) xexp
1522
1522
in
1523
- let should_break_after x = not (is_simple x)
1524
- and should_break_before ((_lbl , exp ) as y ) =
1523
+ let should_break_before x = not (is_simple x)
1524
+ and should_break_after ((_lbl , exp ) as y ) =
1525
1525
match exp.pexp_desc with
1526
1526
(* Heavy syntax strings are not grouped. *)
1527
1527
| Pexp_constant {pconst_desc = Pconst_string (_ , _ , Some _ ); _} -> true
1528
1528
(* Non-simple strings are grouped but end a group. *)
1529
- | Pexp_constant {pconst_desc = Pconst_string (_ , _ , None); _} -> false
1529
+ | Pexp_constant {pconst_desc = Pconst_string (str , _ , None); _} ->
1530
+ String. length str * 3 > c.conf.fmt_opts.margin.v
1530
1531
| _ -> not (is_simple y)
1531
1532
in
1532
1533
let break x y =
Original file line number Diff line number Diff line change 5
5
;;
6
6
7
7
user_error
8
- ( "version mismatch: .ocamlformat requested "
9
- ^ value ^ " but version is " ^ Version.version )
8
+ ( "version mismatch: .ocamlformat requested " ^ value ^ " but version is "
9
+ ^ Version.version )
10
10
;;
11
11
12
12
hvbox 1
You can’t perform that action at this time.
0 commit comments