File tree Expand file tree Collapse file tree 6 files changed +13
-8
lines changed
Cabal-syntax/src/Distribution/Fields
cabal-install/tests/fixtures/init/golden/cabal Expand file tree Collapse file tree 6 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -89,18 +89,23 @@ data Opts ann = Opts
8989 }
9090
9191renderFields :: Opts ann -> [PrettyField ann ] -> [String ]
92- renderFields opts fields = flattenBlocks $ map (renderField opts len) fields
92+ renderFields opts fields = flattenBlocks blocks
9393 where
9494 len = maxNameLength 0 fields
95+ blocks = filter (not . null . _contentsBlock) -- empty blocks cause extra newlines #8236
96+ $ map (renderField opts len) fields
9597
9698 maxNameLength ! acc [] = acc
9799 maxNameLength ! acc (PrettyField _ name _ : rest) = maxNameLength (max acc (BS. length name)) rest
98100 maxNameLength ! acc (PrettySection {} : rest) = maxNameLength acc rest
99101 maxNameLength ! acc (PrettyEmpty : rest) = maxNameLength acc rest
100102
101- -- | Block of lines,
102- -- Boolean parameter tells whether block should be surrounded by empty lines
103- data Block = Block Margin Margin [String ]
103+ -- | Block of lines with flags for optional blank lines before and after
104+ data Block = Block
105+ { _beforeBlock :: Margin
106+ , _afterBlock :: Margin
107+ , _contentsBlock :: [String ]
108+ }
104109
105110data Margin = Margin | NoMargin
106111 deriving Eq
Original file line number Diff line number Diff line change @@ -49,4 +49,3 @@ test-suite y-test
4949 build-depends:
5050 base,
5151 y
52-
Original file line number Diff line number Diff line change @@ -129,4 +129,3 @@ test-suite y-test
129129 build-depends:
130130 base,
131131 y
132-
Original file line number Diff line number Diff line change @@ -37,4 +37,3 @@ test-suite y-test
3737 build-depends:
3838 base,
3939 y
40-
Original file line number Diff line number Diff line change @@ -105,4 +105,3 @@ test-suite y-test
105105 build-depends:
106106 base,
107107 y
108-
Original file line number Diff line number Diff line change 1+ synopsis: cabal init -n: avoid extra blank lines
2+ packages: cabal-init Cabal-syntax
3+ issues: #8236
4+ prs: #8292
You can’t perform that action at this time.
0 commit comments