Skip to content

Commit

Permalink
Fix 197
Browse files Browse the repository at this point in the history
Closes #197
  • Loading branch information
dasJ committed Jun 26, 2024
1 parent c67a7b6 commit 46a6d2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Nixfmt/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,18 @@ indentedStringPart =
TextPart
<$> someText
( chunk "''\\n"
<|> chunk "''\\r"
<|> chunk "''\\t"
<|> chunk "''\\"
*> (Text.singleton <$> anySingle)
<|> chunk "''$"
<|> chunk "'''"
<|> chunk "$$"
<|> try (chunk "$" <* notFollowedBy (char '{'))
<|> try (chunk "'" <* notFollowedBy (char '\''))
<|> someP (\t -> t /= '\'' && t /= '$' && t /= '\n')
<|> chunk "''\\r"
<|> chunk "''\\t"
<|> chunk "''\\'"
<|> chunk "''\\"
-- ''\ followed by any char throws away the ''\ part, leaving just the char
*> (Text.singleton <$> anySingle)
<|> chunk "''$"
<|> chunk "'''"
<|> chunk "$$"
<|> try (chunk "$" <* notFollowedBy (char '{'))
<|> try (chunk "'" <* notFollowedBy (char '\''))
<|> someP (\t -> t /= '\'' && t /= '$' && t /= '\n')
)

indentedLine :: Parser [StringPart]
Expand Down
3 changes: 3 additions & 0 deletions test/correct/regression-197.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
''
''\'''${A}
''

0 comments on commit 46a6d2a

Please sign in to comment.