Skip to content

Commit

Permalink
Fix indentation of '(* cmt *) fun _ ->'
Browse files Browse the repository at this point in the history
  • Loading branch information
Julow committed May 24, 2024
1 parent e2887d5 commit 0e10ae1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,15 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens
update_config_maybe_disabled c pexp_loc pexp_attributes
@@ fun c ->
Cmts.relocate_wrongfully_attached_cmts c.cmts c.source exp ;
let pro = pro $ Cmts.fmt_before c ?eol pexp_loc in
let pro =
(* Some expressions format the 'pro' and comments differently. *)
let cmts_in_pro =
match exp.pexp_desc with
| Pexp_function _ -> noop
| _ -> Cmts.fmt_before c ?eol pexp_loc
in
pro $ cmts_in_pro
in
let fmt_cmts_after k = k $ Cmts.fmt_after c pexp_loc in
let fmt_atrs = fmt_attributes c ~pre:Space pexp_attributes in
let has_attr = not (List.is_empty pexp_attributes) in
Expand Down
13 changes: 13 additions & 0 deletions test/passing/tests/fun_decl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,16 @@ let f ssssssssss =
| '0' -> g accuuuuuuuuuum
| '1' -> h accuuuuuuuuuum
| _ -> i accuuuuuuuuuum )
let f _ =
let foooooooooooooooooooooooooooo = foooooooooooooooooooooooooooo in
fun x ->
let foooooooooooooooooooooooooooo = foooooooooooooooooooooooooooo in
x
let f _ =
let foooooooooooooooooooooooooooo = foooooooooooooooooooooooooooo in
(* foo *)
fun x ->
let foooooooooooooooooooooooooooo = foooooooooooooooooooooooooooo in
x

0 comments on commit 0e10ae1

Please sign in to comment.