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 data MyData = MyData Int
-- after -- after
#test record newline comment
data MyRecord = MyRecord
{ a :: Int
-- comment
, b :: Int
}
#test record comments simple #test record comments simple
data Foo = Bar -- a data Foo = Bar -- a
{ foo :: Baz -- b { foo :: Baz -- b

View File

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