Skip to content

Commit a562c96

Browse files
authoredJan 24, 2024
fix: block strings syntax highlighting in cm6-graphql (#3505)
* fix: block strings syntax highlighting in cm6-graphql * make Description tagged as string
1 parent 7f05c10 commit a562c96

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed
 

‎.changeset/new-tools-unite.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'cm6-graphql': patch
3+
---
4+
5+
fix: block strings syntax highlighting

‎packages/cm6-graphql/__tests__/cases.txt

+32
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,35 @@ Document(
113113
Document(
114114
OperationDefinition(SelectionSet("{",Selection(Field(FieldName)),Selection(Field(FieldName,SelectionSet("{",Selection(Field(FieldName)),"}"))),"}"))
115115
)
116+
117+
118+
119+
# Test case for blockStringCharacter in a Description
120+
121+
"""
122+
This is a block string description
123+
with multiple lines.
124+
It can contain any character except for \""".
125+
"""
126+
type Example {
127+
id: ID
128+
}
129+
130+
==>
131+
132+
Document(
133+
TypeSystemDefinition(
134+
TypeDefinition(
135+
ObjectTypeDefinition(
136+
Description(StringValue),
137+
TypeKeyword(type),
138+
Name,
139+
FieldsDefinition(
140+
"{",
141+
FieldDefinition(Name, NamedType(Name)),
142+
"}"
143+
)
144+
)
145+
)
146+
)
147+
)

‎packages/cm6-graphql/src/language.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const graphqlLanguage = LRLanguage.define({
2020
styleTags({
2121
Variable: t.variableName,
2222
BooleanValue: t.bool,
23+
Description: t.string,
2324
StringValue: t.string,
2425
Comment: t.lineComment,
2526
IntValue: t.integer,

‎packages/cm6-graphql/src/syntax.grammar

+4-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ Name { name }
393393
// https://spec.graphql.org/October2021/#BlockStringCharacter
394394
blockStringCharacter {
395395
'\\"""' |
396-
'"' '"'? !["]
396+
'"' '"'? !["] |
397+
stringCharacter |
398+
'\n' |
399+
'\r\n'
397400
}
398401

399402
// https://spec.graphql.org/October2021/#EscapedUnicode

0 commit comments

Comments
 (0)
Please sign in to comment.