Skip to content

Commit 335a430

Browse files
committed
Formatting: Fix support for code points beyond BMP (0000-FFFF)
1 parent 1340772 commit 335a430

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

src/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'a> Formatter<'a> {
129129
for c in s.chars() {
130130
match c {
131131
'\n' => has_newline = true,
132-
'\r' | '\t' | '\u{0020}'..='\u{FFFF}' => {}
132+
'\r' | '\t' | _ if c >= '\u{0020}' => {}
133133
_ => has_nonprintable = true,
134134
}
135135
}
@@ -143,8 +143,8 @@ impl<'a> Formatter<'a> {
143143
'\t' => self.write(r"\t"),
144144
'"' => self.write("\\\""),
145145
'\\' => self.write(r"\\"),
146-
'\u{0020}'..='\u{FFFF}' => self.buf.push(c),
147-
_ => write!(&mut self.buf, "\\u{:04}", c as u32).unwrap(),
146+
'\u{0000}'..='\u{001F}' => write!(&mut self.buf, "\\u{:04}", c as u32).unwrap(),
147+
_ => self.buf.push(c),
148148
}
149149
}
150150
self.buf.push('"');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
query {
2-
node @dir(a: 1, b: "2", c: true, d: false, e: null)
2+
node @dir(a: 1, b: "2 🤓", c: true, d: false, e: null)
33
}

tests/queries/directive_args_multiline.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
query {
22
node @dir(
33
a: 1,
4-
b: "2",
4+
b: "2 🤓",
55
c: true,
66
d: false,
77
e: null
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
query Foo($site: String = "string") {
1+
query Foo($site: String = "string 🤓") {
22
field
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
query {
2-
node(id: "hello")
2+
node(id: "hello 🤓")
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
query {
22
node(id: """
3-
Hello,
3+
Hello 🤓,
44
world!
55
""")
66
}

0 commit comments

Comments
 (0)