Fix end-of-decl comment spacing issue

ghc92
Lennart Spitzner 2023-05-28 15:47:12 +02:00
parent 5e5433f33a
commit 48522b596c
2 changed files with 17 additions and 8 deletions

View File

@ -1066,3 +1066,9 @@ func = func (abc) (def)
#expected
-- brittany { lconfig_operatorParenthesisRefactorMode: PRMMinimize }
func = func abc def
#test wandering comment at end of datadecl
data ReformatParenMode
= ReformatParenModeKeep -- don't modify parens at all
| ReformatParenModeClean -- remove unnecessary parens
| ReformatParenModeAll -- add superfluous parens everywhere

View File

@ -184,15 +184,18 @@ processModule traceFunc conf inlineConf moduleElems = do
commentToDoc :: (Int, EpaCommentTok) -> ToBriDocM BriDocNumbered
commentToDoc (indent, c) = case c of
GHC.EpaDocCommentNext str -> docLitS (replicate indent ' ' ++ str)
GHC.EpaDocCommentPrev str -> docLitS (replicate indent ' ' ++ str)
GHC.EpaDocCommentNamed str -> docLitS (replicate indent ' ' ++ str)
GHC.EpaDocSection _ str -> docLitS (replicate indent ' ' ++ str)
GHC.EpaDocOptions str -> docLitS (replicate indent ' ' ++ str)
GHC.EpaLineComment str -> docLitS (replicate indent ' ' ++ str)
GHC.EpaBlockComment str -> docLitS (replicate indent ' ' ++ str)
GHC.EpaDocCommentNext str -> handle str
GHC.EpaDocCommentPrev str -> handle str
GHC.EpaDocCommentNamed str -> handle str
GHC.EpaDocSection _ str -> handle str
GHC.EpaDocOptions str -> handle str
GHC.EpaLineComment str -> handle str
GHC.EpaBlockComment str -> handle str
GHC.EpaEofComment -> docEmpty
where
handle str = if indent == 0
then docLitS str
else docSeq [docSeparator, docLitS $ (replicate (indent - 1) ' ') ++ str ]
-- Prints the information associated with the module annotation
-- This includes the imports