Skip to content

Commit 2ee4321

Browse files
committed
Break after 'let%ext'
This avoids patterns being aligned after the end of the extension label: -let%server ( (s : int Eliom_shared.React.S.t) - , (f : (?step:React.step -> int -> unit) Eliom_shared.Value.t) ) = +let%server + ( (s : int Eliom_shared.React.S.t) + , (f : (?step:React.step -> int -> unit) Eliom_shared.Value.t) ) =
1 parent 4c5c7b5 commit 2ee4321

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/Fmt_ast.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4571,7 +4571,6 @@ and fmt_value_binding c ~ctx0 ~rec_flag ?in_ ?epi
45714571
(max (c.conf.fmt_opts.let_binding_indent.v - 1) 0, false)
45724572
| _ -> (c.conf.fmt_opts.let_binding_indent.v, false)
45734573
in
4574-
let pat_has_cmt = Cmts.has_before c.cmts lb_pat.ast.ppat_loc in
45754574
let toplevel, in_, epi, cmts_before, cmts_after =
45764575
match in_ with
45774576
| Some in_ ->
@@ -4591,13 +4590,16 @@ and fmt_value_binding c ~ctx0 ~rec_flag ?in_ ?epi
45914590
, Cmts.Toplevel.fmt_after c lb_loc )
45924591
in
45934592
let ext = lb_attrs.attrs_extension in
4593+
let should_break_after_keyword =
4594+
Cmts.has_before c.cmts lb_pat.ast.ppat_loc || Option.is_some ext
4595+
in
45944596
let decl =
45954597
let decl =
45964598
fmt_str_loc c lb_op
45974599
$ fmt_extension_suffix c ext
45984600
$ fmt_attributes c at_attrs
45994601
$ fmt_if rec_flag (str " rec")
4600-
$ fmt_or pat_has_cmt space_break (str " ")
4602+
$ fmt_or should_break_after_keyword space_break (str " ")
46014603
and pattern = fmt_pattern c lb_pat
46024604
and args =
46034605
fmt_if

test/passing/tests/eliom_ext.eliom

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ type some_type = int * string list [@@deriving json]
2828

2929
type another_type = A of some_type | B of another_type [@@deriving json]]
3030

31-
let%server ( (s : int Eliom_shared.React.S.t)
32-
, (f : (?step:React.step -> int -> unit) Eliom_shared.Value.t) ) =
31+
let%server
32+
( (s : int Eliom_shared.React.S.t)
33+
, (f : (?step:React.step -> int -> unit) Eliom_shared.Value.t) ) =
3334
Eliom_shared.React.S.create 0
3435

3536
let%client incr_s () =

0 commit comments

Comments
 (0)