Skip to content

Fix the indentation produced by max-indent#997

Closed
gpetiot wants to merge 8 commits intoocaml-ppx:masterfrom
gpetiot:fix-max-indent
Closed

Fix the indentation produced by max-indent#997
gpetiot wants to merge 8 commits intoocaml-ppx:masterfrom
gpetiot:fix-max-indent

Conversation

@gpetiot
Copy link
Copy Markdown
Collaborator

@gpetiot gpetiot commented Aug 30, 2019

Fix #925 (in progress)

@gpetiot gpetiot changed the title [WIP] Fix max-indent Fix max-indent Sep 2, 2019
@gpetiot gpetiot requested a review from Julow September 19, 2019 04:50
@Julow
Copy link
Copy Markdown
Collaborator

Julow commented Sep 19, 2019

With max-indent=1 I have this:

 match foooooooooooooooooooooo with
 | ( Ppat_constraint
  ( ({ppat_desc= Ppat_var _; _} as p0)
  , {ptyp_desc= Ptyp_poly ([], t0); _} )
   , Pexp_constraint (e0, t1) )
   when Poly.(t0 = t1) ->
    m.value_binding m

Shoudn't this be like this ?

 match foooooooooooooooooooooo with
 | ( Ppat_constraint
  ( ({ppat_desc= Ppat_var _; _} as p0)
  , {ptyp_desc= Ptyp_poly ([], t0); _} )
  , Pexp_constraint (e0, t1) )
  when Poly.(t0 = t1) ->
   m.value_binding m

@gpetiot
Copy link
Copy Markdown
Collaborator Author

gpetiot commented Sep 19, 2019

(only half-joking) maybe we should only accept --max-indent=i with i >= 2 ?

@Julow
Copy link
Copy Markdown
Collaborator

Julow commented Sep 19, 2019

(the other half-joking) or we could implement it as the max indent a box can add and not on the absolute indentation across lines ?

For example, with max-indent=1, this could be formatted like this:

 match foooooooooooooooooooooo with
 | ( Ppat_constraint
   ( ({ppat_desc= Ppat_var _; _} as p0)
   , {ptyp_desc= Ptyp_poly ([], t0); _} )
  , Pexp_constraint (e0, t1) )
  when Poly.(t0 = t1) ->
   m.value_binding m

Even if the nested tuple is indented 2 spaces more than the line before, it is indented 1 space more than the whole pattern that is indented 1 space more than the whole match

@gpetiot gpetiot changed the title Fix max-indent Fix the indentation produced by max-indent Oct 10, 2019
@gpetiot
Copy link
Copy Markdown
Collaborator Author

gpetiot commented Nov 5, 2019

Replaced by #1118

@gpetiot gpetiot closed this Nov 5, 2019
@gpetiot gpetiot deleted the fix-max-indent branch November 5, 2019 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: inconsistent indentation when using max-indent=2

3 participants