Open chshersh opened 1 month ago
I can confirm the presence of this regression. It's preventing me from upgrading certain projects to OCaml 5.2.0 entirely!
Here's the .ocamlformat
configuration I'm using:
break-cases = all
break-infix = fit-or-vertical
cases-exp-indent = 2
disambiguate-non-breaking-match = true
doc-comments = before
exp-grouping = preserve
field-space = tight-decl
function-indent = 0
if-then-else = keyword-first
indicate-multiline-delimiters = space
indicate-nested-or-patterns = space
let-and = sparse
margin = 106
max-indent = 2
module-item-spacing = sparse
parens-ite = true
parens-tuple = multi-line-only
single-case = sparse
type-decl = sparse
Describe the bug
Actual behaviour: When I pass a
fun
lambda function to another function, the body of the lambda function is indented with 4 spaces whenmax-indent
is explicitly set to twoExpected behaviour: The body is intended with two spaces
How to Reproduce
I have the followating OCaml code in the
test.ml
file:The
.ocamlformat
file is empty.When I format the code with
max-indent=2
andocp-indent-compat
flags,ocamlformat
formats everything with two spaces consistently:However, when I disable
ocp-indent-compat
, thefun
lambda function is indented with 4 spaces (instead of expected 2) despite specifyingmax-indent=2
:In this trivial example,
ocp-indent-compat
affects only spacing, but in a bigger projects, setting this flag to true introduces lots of other undesired changes, so it would be great to have consistent 2 spaces formatting everywhere withoutocp-indent-compat=false
!My system settings:
I'm MacOS Sonoma 14.5 (but I also see this issue on Linux).