Fix record field comment indentation

pull/259/head
Lennart Spitzner 2019-11-08 12:14:01 +01:00 committed by Evan Rutledge Borden
parent c367b1017b
commit 0381b9fe24
2 changed files with 19 additions and 11 deletions

View File

@ -392,6 +392,13 @@ data Foo = forall a b . (Show a, Eq b) => Bar
data MyData = MyData Int
-- after
#test record newline comment
data MyRecord = MyRecord
{ a :: Int
-- comment
, b :: Int
}
#test record comments simple
data Foo = Bar -- a
{ foo :: Baz -- b

View File

@ -291,21 +291,22 @@ createDetailsDoc consNameStr details = case details of
IndentPolicyFree -> docAlt [singleLine, multiIndented]
RecCon (L _ []) -> docEmpty
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
RecCon lRec@(L _ [lField@(L _ (ConDeclField _ext names t _))]) -> docSeq
RecCon lRec@(L _ [lField@(L _ (ConDeclField _ext names t _))]) ->
#else
RecCon lRec@(L _ [lField@(L _ (ConDeclField names t _))]) -> docSeq
RecCon lRec@(L _ [lField@(L _ (ConDeclField names t _))]) ->
#endif
[ docLit consNameStr
, docSeparator
, docWrapNodePrior lRec $ docLit $ Text.pack "{"
, docSeparator
, docWrapNodeRest lRec $ docSeq $ createNamesAndTypeDoc lField names t
, docSeparator
, docLit $ Text.pack "}"
]
docSetIndentLevel $ docSeq
[ docLit consNameStr
, docSeparator
, docWrapNodePrior lRec $ docLit $ Text.pack "{"
, docSeparator
, docWrapNodeRest lRec $ docSeq $ fmap docForceSingleline $ createNamesAndTypeDoc lField names t
, docSeparator
, docLit $ Text.pack "}"
]
RecCon lRec@(L _ fields@(_:_)) -> do
let (fDoc1 : fDocR) = mkFieldDocs fields
docAddBaseY BrIndentRegular $ docPar
docAddBaseY BrIndentRegular $ docSetIndentLevel $ docPar
(docLit consNameStr)
(docWrapNodePrior lRec $ docLines
[ docCols ColRecDecl