Skip to content

Fix same line do block#115

Merged
brandonchinn178 merged 4 commits intomasterfrom
fix-same-line-do-block
Oct 3, 2021
Merged

Fix same line do block#115
brandonchinn178 merged 4 commits intomasterfrom
fix-same-line-do-block

Conversation

@brandonchinn178
Copy link
Copy Markdown
Collaborator

Resolves #114

Comment on lines +404 to 410
inciBy step (R m) = R (local modRC m)
where
modRC rc =
rc
{ rcIndent = roundDownToNearest step (rcIndent rc) + step
}
roundDownToNearest r n = (n `div` r) * r
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now this matches Ormolu's version (modulo roundDownToNearest)

Comment on lines +607 to +609
| isOneLineSpan (getLoc func) = inci
| isOneLineSpan (getLoc func) = case unLoc func of
HsDo {} -> inciBy 2
_ -> inci
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worked in Ormolu because their indentation size is hardcoded to 2. It seems like for the case of a do-block in a one-line span, the indentation size should be exactly 2 (or 1 might work), regardless of the indentation setting

Copy link
Copy Markdown
Collaborator

@georgefst georgefst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@brandonchinn178 brandonchinn178 merged commit 408c3bb into master Oct 3, 2021
@brandonchinn178 brandonchinn178 deleted the fix-same-line-do-block branch October 3, 2021 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix test for same-line do-block

2 participants