File tree Expand file tree Collapse file tree 8 files changed +31
-16
lines changed Expand file tree Collapse file tree 8 files changed +31
-16
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ profile. This started with version 0.26.0.
58
58
The attribute is moved from ` begin .. end [@attr] ` to ` begin [@attr] .. end ` .
59
59
- Fix missing parentheses around ` let .. in [@attr] ` (#2564 , @Julow )
60
60
- Display ` a##b ` instead of ` a ## b ` and similarly for operators that start with # (#2580 , @v-gb )
61
+ - Fix formatting of short ` fun ` expressions with the janestreet profile (#2593 , @Julow )
61
62
62
63
### Changes
63
64
- The location of attributes for structure items is now tracked and preserved. (#2247 , @EmileTrotignon )
Original file line number Diff line number Diff line change @@ -1509,7 +1509,7 @@ and fmt_function ?(last_arg = false) ?force_closing_paren ~ctx ~ctx0
1509
1509
let head = fmt_fun_args_typ args typ in
1510
1510
let body ~pro = pro $ fmt_expression c (sub_exp ~ctx body) in
1511
1511
let box, closing_paren_offset =
1512
- Params.Exp. box_fun_expr c.conf ~source: c.source ~ctx0 ~ctx ~parens
1512
+ Params.Exp. box_fun_expr c.conf ~source: c.source ~ctx0 ~ctx
1513
1513
in
1514
1514
let closing_paren_offset =
1515
1515
if should_box then closing_paren_offset else ~- 2
Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ module Exp = struct
213
213
( kw_in_box
214
214
$ hvbox_if should_box_args 0 (args $ fmt_opt annot $ fmt_opt epi) )
215
215
216
- let box_fun_expr (c : Conf.t ) ~source ~ctx0 ~ctx ~ parens =
216
+ let box_fun_expr (c : Conf.t ) ~source ~ctx0 ~ctx =
217
217
let indent =
218
218
if ctx_is_rhs_of_infix ~ctx0 ~ctx then 0
219
219
else if Poly. equal c.fmt_opts.function_indent_nested.v `Always then
@@ -244,14 +244,7 @@ module Exp = struct
244
244
else 2
245
245
in
246
246
let name = " Params.box_fun_expr" in
247
- let mkbox =
248
- match ctx0 with
249
- | Str _ | Lb _ -> hvbox
250
- | _ ->
251
- (* JS: The body of a [fun] must break if the intro is too large,
252
- except if the [fun] is small and parenthesed. *)
253
- if ocp c && not parens then hvbox else hovbox
254
- in
247
+ let mkbox = if ctx_is_let_or_fun ~ctx ctx0 then hvbox else hovbox in
255
248
(mkbox ~name indent, ~- indent)
256
249
257
250
(* if the function is the last argument of an apply and no other arguments
Original file line number Diff line number Diff line change @@ -58,7 +58,6 @@ module Exp : sig
58
58
-> source :Source .t
59
59
-> ctx0 :Ast .t
60
60
-> ctx :Ast .t
61
- -> parens :bool
62
61
-> (Fmt .t -> Fmt .t ) * int
63
62
(* * return a box with an indent and minus the value of the indent to be used for a closing parenthesis *)
64
63
Original file line number Diff line number Diff line change @@ -8241,3 +8241,11 @@ let _ =
8241
8241
(* foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *)
8242
8242
else f
8243
8243
;;
8244
+
8245
+ let _ =
8246
+ match ids_queue with
8247
+ | Some q ->
8248
+ (* this is more efficient than a linear scan of [ids] *)
8249
+ fun id -> not (Ident.HashQueue. mem q id)
8250
+ | None -> fun id -> not (List. mem ~equal: Ident. equal ids id)
8251
+ ;;
Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ Warning: tests/js_source.ml:9564 exceeds the margin
3
3
Warning: tests/js_source.ml:9668 exceeds the margin
4
4
Warning: tests/js_source.ml:9727 exceeds the margin
5
5
Warning: tests/js_source.ml:9810 exceeds the margin
6
- Warning: tests/js_source.ml:10309 exceeds the margin
6
+ Warning: tests/js_source.ml:10308 exceeds the margin
Original file line number Diff line number Diff line change @@ -10235,8 +10235,7 @@ let _ =
10235
10235
foooooooooooooooooo
10236
10236
foooooooooooooooooo
10237
10237
foooooooooooooooooo
10238
- foooooooooooooooooo ->
10239
- ()
10238
+ foooooooooooooooooo -> ()
10240
10239
;;
10241
10240
10242
10241
module type For_let_syntax_local =
@@ -10530,3 +10529,11 @@ let _ =
10530
10529
(* foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *)
10531
10530
else f
10532
10531
;;
10532
+
10533
+ let _ =
10534
+ match ids_queue with
10535
+ | Some q ->
10536
+ (* this is more efficient than a linear scan of [ids] *)
10537
+ fun id -> not (Ident.HashQueue.mem q id)
10538
+ | None -> fun id -> not (List.mem ~equal:Ident.equal ids id)
10539
+ ;;
Original file line number Diff line number Diff line change @@ -10235,8 +10235,7 @@ let _ =
10235
10235
foooooooooooooooooo
10236
10236
foooooooooooooooooo
10237
10237
foooooooooooooooooo
10238
- foooooooooooooooooo ->
10239
- ()
10238
+ foooooooooooooooooo -> ()
10240
10239
;;
10241
10240
10242
10241
module type For_let_syntax_local =
@@ -10530,3 +10529,11 @@ let _ =
10530
10529
(* foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo *)
10531
10530
else f
10532
10531
;;
10532
+
10533
+ let _ =
10534
+ match ids_queue with
10535
+ | Some q ->
10536
+ (* this is more efficient than a linear scan of [ids] *)
10537
+ fun id -> not (Ident.HashQueue.mem q id)
10538
+ | None -> fun id -> not (List.mem ~equal:Ident.equal ids id)
10539
+ ;;
You can’t perform that action at this time.
0 commit comments