Skip to content

Commit 7c31cac

Browse files
committed
Apply atom quoting fix to inline-plz too
1 parent c3ee210 commit 7c31cac

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/language/unparsing/inline-plz.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@ const arrow = kleur.dim('=>')
3030
const escapeStringContents = (value: string) =>
3131
value.replace('\\', '\\\\').replace('"', '\\"')
3232

33-
const quoteIfNecessary = (value: string) =>
34-
!either.isLeft(unquotedAtomParser(value))
35-
? value
36-
: quote.concat(escapeStringContents(value)).concat(quote)
33+
const quoteIfNecessary = (value: string) => {
34+
const unquotedAtomResult = unquotedAtomParser(value)
35+
if (
36+
either.isLeft(unquotedAtomResult) ||
37+
unquotedAtomResult.value.remainingInput.length !== 0
38+
) {
39+
return quote.concat(escapeStringContents(value)).concat(quote)
40+
} else {
41+
return value
42+
}
43+
}
3744

3845
const atom = (node: string): Right<string> =>
3946
either.makeRight(

0 commit comments

Comments
 (0)