Skip to content
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/kind-dodos-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vscode-apollo": patch
---

Improve syntax highlighting for GraphQL block strings
14 changes: 14 additions & 0 deletions syntaxes/graphql.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,19 @@
"1": { "name": "constant.language.null.graphql" }
}
},
"graphql-block-string-value": {
"contentName": "string.quoted.triple.block.graphql",
"begin": "\\s*+((\"\"\"))",
"end": "\\s*+((\"\"\"))",
Comment on lines +490 to +491

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to capture the optional whitespace before the """ in both the start and end of the block string? Would just capturing """ be enough?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this might be a dumb question but what does \s*+ mean?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\s*+ is just possessive matching of whitespace. Since the existing string.quoted.double.graphql is using possessive whitespace matching already, we need to use it here as well, or it ends up matching the other pattern since possessive whitespace followed by one " also matches whitespace followed by """.

"beginCaptures": {
"1": { "name": "string.quoted.triple.block.graphql" },
"2": { "name": "punctuation.definition.string.begin.graphql" }
},
"endCaptures": {
"1": { "name": "string.quoted.triple.block.graphql" },
"2": { "name": "punctuation.definition.string.end.graphql" }
}
},
"graphql-string-value": {
"contentName": "string.quoted.double.graphql",
"begin": "\\s*+((\"))",
Expand Down Expand Up @@ -553,6 +566,7 @@
"patterns": [
{ "include": "#graphql-variable-name" },
{ "include": "#graphql-float-value" },
{ "include": "#graphql-block-string-value" },
{ "include": "#graphql-string-value" },
{ "include": "#graphql-boolean-value" },
{ "include": "#graphql-null-value" },
Expand Down