Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: block strings syntax highlighting in cm6-graphql #3505

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-tools-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'cm6-graphql': patch
---

fix: block strings syntax highlighting
32 changes: 32 additions & 0 deletions packages/cm6-graphql/__tests__/cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,35 @@ Document(
Document(
OperationDefinition(SelectionSet("{",Selection(Field(FieldName)),Selection(Field(FieldName,SelectionSet("{",Selection(Field(FieldName)),"}"))),"}"))
)



# Test case for blockStringCharacter in a Description

"""
This is a block string description
with multiple lines.
It can contain any character except for \""".
"""
type Example {
id: ID
}

==>

Document(
TypeSystemDefinition(
TypeDefinition(
ObjectTypeDefinition(
Description(StringValue),
TypeKeyword(type),
Name,
FieldsDefinition(
"{",
FieldDefinition(Name, NamedType(Name)),
"}"
)
)
)
)
)
1 change: 1 addition & 0 deletions packages/cm6-graphql/src/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const graphqlLanguage = LRLanguage.define({
styleTags({
Variable: t.variableName,
BooleanValue: t.bool,
Description: t.string,
StringValue: t.string,
Comment: t.lineComment,
IntValue: t.integer,
Expand Down
5 changes: 4 additions & 1 deletion packages/cm6-graphql/src/syntax.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ Name { name }
// https://spec.graphql.org/October2021/#BlockStringCharacter
blockStringCharacter {
'\\"""' |
'"' '"'? !["]
'"' '"'? !["] |
stringCharacter |
'\n' |
'\r\n'
}

// https://spec.graphql.org/October2021/#EscapedUnicode
Expand Down