diff --git a/src/Nixfmt/Lexer.hs b/src/Nixfmt/Lexer.hs index 1cbb798e..b34edecf 100644 --- a/src/Nixfmt/Lexer.hs +++ b/src/Nixfmt/Lexer.hs @@ -71,7 +71,7 @@ lineComment :: Parser ParseTrivium lineComment = preLexeme $ do SourcePos{sourceColumn = col} <- getSourcePos _ <- chunk "#" - text <- manyP (\x -> x /= '\n' && x /= '\r') + text <- stripEnd <$> manyP (\x -> x /= '\n' && x /= '\r') return (PTLineComment text col) blockComment :: Parser ParseTrivium diff --git a/test/diff/strip_space/in.nix b/test/diff/strip_space/in.nix new file mode 100644 index 00000000..00b0ca66 --- /dev/null +++ b/test/diff/strip_space/in.nix @@ -0,0 +1,10 @@ +/* + a + b +*/ +# a +# b +{ + a = 1; + b = 2; +} diff --git a/test/diff/strip_space/out-pure.nix b/test/diff/strip_space/out-pure.nix new file mode 100644 index 00000000..60082668 --- /dev/null +++ b/test/diff/strip_space/out-pure.nix @@ -0,0 +1,10 @@ +/* + a + b +*/ +# a +# b +{ + a = 1; + b = 2; +} diff --git a/test/diff/strip_space/out.nix b/test/diff/strip_space/out.nix new file mode 100644 index 00000000..60082668 --- /dev/null +++ b/test/diff/strip_space/out.nix @@ -0,0 +1,10 @@ +/* + a + b +*/ +# a +# b +{ + a = 1; + b = 2; +}