Skip to content

Commit ca4e35d

Browse files
committed
PrettyPrint: 'switch' to use ordinary block syntax for case clauses
1 parent 1ac4322 commit ca4e35d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Language/ECMAScript3/PrettyPrint.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ instance Pretty (Statement a) where
6565
else indented 3 alt
6666
SwitchStmt _ e cases ->
6767
text "switch" <+> parens (ppExpression True e) <> line <>
68-
braces (nest 3 (vcat (map prettyPrint cases)))
68+
ppBlock 2 (vcat (map prettyPrint cases))
6969
WhileStmt _ test body -> text "while" <+> parens (ppExpression True test) </>
7070
indented 3 body
7171
ReturnStmt _ Nothing -> text "return" <> semi
@@ -259,7 +259,10 @@ inBlock s = asBlock [s]
259259

260260
asBlock :: [Statement a] -> Doc
261261
asBlock [] = lbrace <$$> rbrace
262-
asBlock ss = lbrace <> nest 3 (line <> prettyPrint ss) <$$> rbrace
262+
asBlock ss = ppBlock 3 (prettyPrint ss)
263+
264+
ppBlock :: Int -> Doc -> Doc
265+
ppBlock width doc = lbrace <> nest width (line <> doc) <$$> rbrace
263266

264267
ppVarDecl :: Bool -> VarDecl a -> Doc
265268
ppVarDecl hasIn vd = case vd of

0 commit comments

Comments
 (0)