Skip to content

Commit

Permalink
Fix trailing space not being stripped in single-line comments
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Aug 29, 2024
1 parent 783dbd8 commit 0baa6da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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
4 changes: 2 additions & 2 deletions test/diff/strip_space/out-pure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
a
b
*/
# a
# b
# a
# b
{
a = 1;
b = 2;
Expand Down
4 changes: 2 additions & 2 deletions test/diff/strip_space/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
a
b
*/
# a
# b
# a
# b
{
a = 1;
b = 2;
Expand Down

0 comments on commit 0baa6da

Please sign in to comment.