Skip to content

Commit c6b66f7

Browse files
author
Erin van der Veen
authored
Merge pull request #745 from tweag/nb/ocaml_indentation
Indentation on multi-line call containing functions
2 parents 2be4b84 + 2f14687 commit c6b66f7

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This name should be decided amongst the team before the release.
4949

5050
### Fixed
5151
- [#720](https://github.com/tweag/topiary/pull/720) [#722](https://github.com/tweag/topiary/pull/722) [#723](https://github.com/tweag/topiary/pull/723) [#724](https://github.com/tweag/topiary/pull/724) [#735](https://github.com/tweag/topiary/pull/735)
52-
[#738](https://github.com/tweag/topiary/pull/738) [#739](https://github.com/tweag/topiary/pull/739) Various OCaml improvements
52+
[#738](https://github.com/tweag/topiary/pull/738) [#739](https://github.com/tweag/topiary/pull/739) [#745](https://github.com/tweag/topiary/pull/745) Various OCaml improvements
5353

5454
### Changed
5555
- [#704](https://github.com/tweag/topiary/pull/704) Refactors our postprocessing code to be more versatile.

topiary-cli/tests/samples/expected/ocaml.ml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,8 @@ let () =
11871187

11881188
let () =
11891189
foo x (fun y ->
1190-
zzzzzzzzzz
1191-
)
1190+
zzzzzzzzzz
1191+
)
11921192

11931193
let foo x = function
11941194
| y -> zzzzzzzzzz
@@ -1206,9 +1206,9 @@ let () =
12061206

12071207
let () =
12081208
foo x (function
1209-
| y -> zzzzzzzzzz
1210-
| u -> vvvvvvvvv
1211-
)
1209+
| y -> zzzzzzzzzz
1210+
| u -> vvvvvvvvv
1211+
)
12121212

12131213
(* #727 proper formatting of multi-lined typed function argument *)
12141214
let foo
@@ -1241,6 +1241,17 @@ type x = [> `Foo | `Bar]
12411241
type x = [< `Foo | `Bar]
12421242
type x = {a: int; b: int; c: int}
12431243

1244+
(* #726 multi-line calls containing functions *)
1245+
let _ =
1246+
foo
1247+
bar
1248+
(fun baz ->
1249+
baaaaaaz
1250+
)
1251+
(fun qux ->
1252+
quuuuuux
1253+
)
1254+
12441255
(* #659 handling of the `;;` separator *)
12451256

12461257
let bonjour () = "Bonjour"

topiary-cli/tests/samples/input/ocaml.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,17 @@ type x = [> `Foo | `Bar]
11821182
type x = [< `Foo | `Bar]
11831183
type x = { a: int; b: int; c: int }
11841184

1185+
(* #726 multi-line calls containing functions *)
1186+
let _ =
1187+
foo
1188+
bar
1189+
(fun baz ->
1190+
baaaaaaz
1191+
)
1192+
(fun qux ->
1193+
quuuuuux
1194+
)
1195+
11851196
(* #659 handling of the `;;` separator *)
11861197

11871198
let bonjour () = "Bonjour"

topiary-queries/queries/ocaml.scm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,12 +1157,14 @@
11571157
; _before_ the application. This allows the following to be formatted as such:
11581158
; let () =
11591159
; foo bar (fun x ->
1160-
; something horrible onto x
1161-
; )
1160+
; something horrible onto x
1161+
; )
11621162
(application_expression
11631163
.
1164-
(_) @prepend_begin_scope @append_indent_start
1164+
(_) @append_indent_start @prepend_begin_scope
11651165
(#scope_id! "function_application")
1166+
(_) @append_indent_end
1167+
.
11661168
)
11671169
(application_expression
11681170
(#scope_id! "function_application")
@@ -1171,7 +1173,7 @@
11711173
(fun_expression)
11721174
(function_expression)
11731175
]? @do_nothing
1174-
) @append_end_scope @append_indent_end
1176+
) @append_end_scope
11751177
.
11761178
)
11771179
(application_expression
@@ -1180,8 +1182,8 @@
11801182
[
11811183
(fun_expression)
11821184
(function_expression)
1183-
]
1184-
) @prepend_end_scope @prepend_indent_end
1185+
] @prepend_end_scope
1186+
)
11851187
.
11861188
)
11871189
(application_expression

0 commit comments

Comments
 (0)