Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong indentation in pretty printer #56

Open
sureyeaah opened this issue Dec 3, 2019 · 4 comments
Open

Wrong indentation in pretty printer #56

sureyeaah opened this issue Dec 3, 2019 · 4 comments

Comments

@sureyeaah
Copy link
Contributor

Reproduce:

pPrint( ((1, 2), 3, (4)) )

Current behavior

( 
    ( 1
    , 2
    ) 
, 3
, ( 4 )
) 

Expected behavior: First tuple should be aligned with the rest of the elements.

( 
  ( 1
  , 2
  ) 
, 3
, ( 4 )
) 

Is the current behavior intentional?

@cdepillabout
Copy link
Owner

@sureyeaah I don't remember if this behavior is intentional or not, but I agree that it doesn't make any sense.

If you want to fix this when working on #25, please feel free.

@georgefst
Copy link
Collaborator

The 'expected behaviour' here is actually precisely what you get with pPrintStringOpt (defaultOutputOptionsDarkBg {outputOptionsIndentAmount = 2}).

As for how leading commas and four space indentation should interact, I've been pondering that while working on Fourmolu, where the status quo is close to your expected output, but that actually leads to a weird mix of two- and four-space indentation that I'm not happy with. So the current pretty-simple output is close to what I'm intending to implement there... What don't you like about it?

@sureyeaah
Copy link
Contributor Author

sureyeaah commented Aug 14, 2020

Well what i don't like about the current behaviour as described in the issue is that it makes no sense. Why are the first element's paranthesis indented with 4 spaces while third with 2 - doesn't seem right.

If the expected behaviour is what pretty simple produces then this is resolved.

@georgefst
Copy link
Collaborator

Why are the first element's parantheses indented with 4 spaces while third with 2 - doesn't seem right.

Because in a sense the third subexpression isn't really indented at all. Regardless of the indentation step, there's just the one space after the comma.

You could have this, but I think it looks weird:

( 
    ( 1
    , 2
    ) 
,     3
,   ( 4 )
) 

I think if you care about those lining up, you have to just use 2 space indentation. I've never seen a good solution with 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants