Skip to content

Commit b2eccf1

Browse files
Don't indent closing paren where possible
1 parent 67ca057 commit b2eccf1

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
3+
* Don't indent closing parentheses for tuples where possible
4+
15
## Ormolu 0.7.4.0
26

37
* Don't error when the `JavaScriptFFI` language pragma is present. [Issue

data/examples/declaration/value/function/arrow/proc-applications-out.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bar f x =
99
( y,
1010
z,
1111
w
12-
)
12+
)
1313
->
1414
f -- The value
1515
-<

data/examples/declaration/value/function/arrow/proc-do-complex-out.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ foo
99
( (a, b),
1010
(c, d),
1111
(e, f)
12-
)
12+
)
1313
-> do
1414
-- Begin do
1515
(x, y) <- -- GHC parser fails if layed out over multiple lines

src/Ormolu/Printer/Meat/Declaration/Value.hs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1057,11 +1057,19 @@ p_pat style = \case
10571057
ListPat _ pats ->
10581058
brackets S $ sep commaDel (located' p_pat') pats
10591059
TuplePat _ pats boxing -> do
1060+
let parenStyle =
1061+
case style of
1062+
-- don't indent closing paren if possible, because it's
1063+
-- prettier. but closing paren must be indented in case
1064+
-- statements or it's a syntax error.
1065+
Case -> S
1066+
LambdaCase -> S
1067+
_ -> N
10601068
let parens' =
10611069
case boxing of
1062-
Boxed -> parens S
1063-
Unboxed -> parensHash S
1064-
parens' $ sep commaDel (sitcc . located' p_pat') pats
1070+
Boxed -> parens
1071+
Unboxed -> parensHash
1072+
parens' parenStyle $ sep commaDel (sitcc . located' p_pat') pats
10651073
SumPat _ pat tag arity ->
10661074
p_unboxedSum S tag arity (located pat p_pat')
10671075
ConPat _ pat details ->

0 commit comments

Comments
 (0)