diff --git a/src/Nixfmt/Lexer.hs b/src/Nixfmt/Lexer.hs index 7a97a1a7..760aa291 100644 --- a/src/Nixfmt/Lexer.hs +++ b/src/Nixfmt/Lexer.hs @@ -84,7 +84,16 @@ blockComment = try $ preLexeme $ do isDoc <- try ((True <$ char '*') <* notFollowedBy (char '/')) <|> pure False chars <- manyTill anySingle $ chunk "*/" - return $ PTBlockComment isDoc $ dropWhile Text.null $ fixIndent pos' $ removeStars pos' $ splitLines $ pack chars + return + . PTBlockComment isDoc + . dropWhile Text.null + . fixIndent pos' + . dropWhileEnd Text.null + . map Text.stripEnd + . removeStars pos' + . splitLines + . pack + $ chars where -- Normalize line ends and stuff splitLines :: Text -> [Text] diff --git a/test/diff/comment/in.nix b/test/diff/comment/in.nix index a3f2bfa5..aa81b7a3 100644 --- a/test/diff/comment/in.nix +++ b/test/diff/comment/in.nix @@ -42,6 +42,11 @@ * test */ + /* test + * test + * + */ + /* * FOO */ diff --git a/test/diff/comment/out.nix b/test/diff/comment/out.nix index c9e956c6..138f59c0 100644 --- a/test/diff/comment/out.nix +++ b/test/diff/comment/out.nix @@ -36,6 +36,11 @@ test */ + /* + test + test + */ + # FOO /**