Fix pretty printing of EscapedNewline
This commit is contained in:
parent
58f17e837a
commit
ed089f57b8
|
@ -221,7 +221,7 @@ nixString = lexeme (doubleQuoted <+> indented <?> "string")
|
|||
(Plain <$> ("''" <$ char '\'' <+> "$" <$ char '$')) <+> do
|
||||
_ <- char '\\'
|
||||
c <- escapeCode
|
||||
pure $ if c == '\n'
|
||||
pure $ if c == 'n'
|
||||
then EscapedNewline
|
||||
else Plain $ singleton c
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ wrapParens op sub
|
|||
prettyString :: NString NixDoc -> Doc
|
||||
prettyString (DoubleQuoted parts) = dquotes . hcat . map prettyPart $ parts
|
||||
where prettyPart (Plain t) = text . concatMap escape . unpack $ t
|
||||
prettyPart EscapedNewline = text "\n"
|
||||
prettyPart EscapedNewline = text "''\\n"
|
||||
prettyPart (Antiquoted r) = text "$" <> braces (withoutParens r)
|
||||
escape '"' = "\\\""
|
||||
escape x = maybe [x] (('\\':) . (:[])) $ toEscapeCode x
|
||||
|
@ -102,7 +102,7 @@ prettyString (Indented _ parts)
|
|||
f xs = xs
|
||||
prettyLine = hcat . map prettyPart
|
||||
prettyPart (Plain t) = text . unpack . replace "${" "''${" . replace "''" "'''" $ t
|
||||
prettyPart EscapedNewline = text "\n"
|
||||
prettyPart EscapedNewline = text "\\n"
|
||||
prettyPart (Antiquoted r) = text "$" <> braces (withoutParens r)
|
||||
|
||||
prettyParams :: Params NixDoc -> Doc
|
||||
|
|
Loading…
Reference in a new issue