Skip to content

Commit 05bf65d

Browse files
authored
Merge pull request #324 from Julow/struct-let
Fix detection of Let vs LetIn after a 'struct'
2 parents 0c32a17 + 363a9d2 commit 05bf65d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/indentBlock.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,15 @@ let rec update_path config block stream tok =
937937
(* Two ways to detect let vs letin ;
938938
both seem to work, but need to check which one
939939
is the most robust (for example w.r.t. unfinished expressions) *)
940-
(* - it's a top Let if it is after a closed expression *)
940+
(* it's a top Let if it is:
941+
- after a closed expression
942+
- inside a [struct]
943+
- after [type = |]
944+
*)
941945
(match block.path with
942946
| {kind=KExpr i}::p when i = prio_max ->
943947
append KLet L (unwind_top p)
944-
| [] | {kind=KCodeInComment}::_ | {kind=KBar KType}::_ as p->
948+
| [] | {kind=KCodeInComment | KBar KType | KStruct}::_ as p->
945949
append KLet L (unwind_top p)
946950
| _ ->
947951
append KLetIn L (fold_expr block.path))

tests/passing/module.t

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@
6060
> with type t1 = t1'
6161
> and type t2 = t2')
6262
>
63+
> (* Detection of [Let] vs [LetIn] inside a [struct]. *)
64+
> module M = struct
65+
> let indentation_after_fun =
66+
> fun foo ->
67+
> bar
68+
> end
69+
>
70+
> (* Unfinished [struct] *)
6371
> module Store (K: API.KEY) (V: API.VALUE) :
6472
> API.STORE with module K = K
6573
> and module V = V =
@@ -129,6 +137,14 @@
129137
with type t1 = t1'
130138
and type t2 = t2')
131139

140+
(* Detection of [Let] vs [LetIn] inside a [struct]. *)
141+
module M = struct
142+
let indentation_after_fun =
143+
fun foo ->
144+
bar
145+
end
146+
147+
(* Unfinished [struct] *)
132148
module Store (K: API.KEY) (V: API.VALUE) :
133149
API.STORE with module K = K
134150
and module V = V =

0 commit comments

Comments
 (0)