Skip to content

Commit

Permalink
Merge pull request #247 from NixOS/strip-trailing-space
Browse files Browse the repository at this point in the history
Always strip trailing space
  • Loading branch information
0x4A6F authored Sep 3, 2024
2 parents 2a1100d + 0baa6da commit 2efce29
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nixfmt/Lexer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/diff/strip_space/in.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
a
b
*/
# a
# b
{
a = 1;
b = 2;
}
10 changes: 10 additions & 0 deletions test/diff/strip_space/out-pure.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
a
b
*/
# a
# b
{
a = 1;
b = 2;
}
10 changes: 10 additions & 0 deletions test/diff/strip_space/out.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
a
b
*/
# a
# b
{
a = 1;
b = 2;
}

0 comments on commit 2efce29

Please sign in to comment.