Open plaa opened 5 years ago
This is definitely still an issue a year later.
yikes still an issue. new maintainer here! let's get this one.
my guess is the fix can be introduced to this block of the grammar, if anyone wants to start on a PR. otherwise I will get to this one in the next few weeks https://github.com/prisma-labs/vscode-graphql/blob/6bdfa89e63f737134b2d9a6a4e8959092b0e2fbf/grammars/graphql.json#L58
I would like to work on this issue if it's still open @plaa I have been doing web development in javascript for a year now and would like to enter the open source world.
@hkumar0132 I am unaware of it being fixed. I have moved to another project and am no longer using GraphQL, so I cannot verify. Probably @acao can comment.
@plaa Thanks for the response. Just wanna know if it's a good issue to solve for a beginner?
@hkumar0132 possibly? if you’re familiar with regular expressions then definately. all these issues labelled “grammar” will just involve modifying the expressions in the grammar json files. here’s where to get started:
I just spent some hours to see if I could learn something about grammars and be able to fix it. With my very limited knowledge, what I found out was that as soon as the {
is in a new line, it gets the meta.selectionset.graphql
scope.
So if I modify the graphql-operation-def
entry in the grammar file, to include #graphql-type-object
before #graphql-selection-set
then it all seemed to work fine.
Unfortunately I am unaware of side effects of this change and probably will need several more hours to learn grammars, so I'm hoping it at leasts helps someone else.
"graphql-operation-def": {
"patterns": [
{ "include": "#graphql-query-mutation" },
{ "include": "#graphql-name" },
{ "include": "#graphql-variable-definitions" },
{ "include": "#graphql-directive" },
{ "include": "#graphql-type-object" }, // added this
{ "include": "#graphql-selection-set" }
]
},
I really appreciate this @abc-moviestarplanet! I will test this out some more but this looks like it's what we need to fix this issue. My few fixes to the grammar files since taking over have happened similarly.
Actual Behavior
Field coloring varies depending whether the opening brace or directive is on the same line as the type definition. Especially in more complex cases (the Bar example below) it may be preferable to have directives on their own lines.
See
field: String
below:Expected Behavior
Colors don't change based on locations.
Steps to Reproduce the Problem Or Description
Example code from screenshot:
Specifications