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

[vscode-graphql-syntax] Ruby GRAPHQL heredoc breaks syntax higlighting in the file #3524

Open
danieldiekmeier opened this issue Jan 31, 2024 · 7 comments

Comments

@danieldiekmeier
Copy link

Current Behavior

A few weeks ago, the vscode-graphql-syntax package added Ruby support (#3490), but I think something is not quite right.

This is what the example file packages/vscode-graphql-syntax/tests/__fixtures__/test.rb looks like in my VS Code, running the latest extension v1.3.1:

image

As you can see, while the GraphQL is highlighted, it breaks the highlighting of following Ruby code.

Looking at the tests, I noticed how the snapshots for Ruby and e.g. Python are very different.

Ruby (actual GraphQL lines don't have an annotation on the right):

<<~ | taggedTemplates meta.embedded.block.graphql
GRAPHQL | taggedTemplates punctuation.definition.string.end.ruby
{ |
datasets(q: { idEq: 3 }) { id, daylight } |
} |
GRAPHQL |
data = Util.graphql_query(query) |

Python (actual GraphQL lines are annotated):

""" | meta.embedded.block.graphql string.quoted.multi.python
| meta.embedded.block.graphql
query | meta.embedded.block.graphql keyword.operation.graphql
| meta.embedded.block.graphql
getContinents | meta.embedded.block.graphql entity.name.function.graphql
| meta.embedded.block.graphql meta.selectionset.graphql

It looks like the Ruby grammar recognizes the start of the Heredocs also as the end of the Heredoc, maybe confusing itself in the process? I don't understand a lot about the grammars, and fiddling around with the Regexes I wasn't able to produce a better result.

Expected Behavior

I'd expect the closing GRAPHQL at the end of the Heredoc to end the code block and reactivate the Ruby syntax highlighting.

@krishantaylor
Copy link

I was able to fix this locally by removing the ruby syntax addition entirely (edit package.json and remove the grammar file). The grammar from the "Ruby LSP" extension hands things off to the graphql syntax highlighter correctly, and matches for both the GRAPHQL and GQL heredoc identifiers. Alternatively, just switching to GQL identifiers might do the trick, as "Ruby LSP" will still hand things off this extension without triggering its problematic grammar—which is only triggered by GRAPHQL.

@berniechiu
Copy link

GQL doesn't seem to highlight correctly either

@acao
Copy link
Member

acao commented Apr 25, 2024

if someone wants to fix it, it is just a textmate grammar, so it's a set of regular expressions. should i just remove it for now? is no highlighting better than the current bugs?

@acao acao closed this as completed Apr 25, 2024
@acao acao reopened this Apr 25, 2024
@danieldiekmeier
Copy link
Author

As @krishantaylor said, it’d still get highlighted because Ruby LSP hands it off correctly. (At least for me, you probably need to have the Ruby LSP extension.) It would definitely be better than breaking following Ruby code for the rest of the file.

@krishantaylor
Copy link

I'd rather see it removed. Ruby LSP is the current recommended extension for ruby anyway.

@acao
Copy link
Member

acao commented Apr 25, 2024

removal it is!

@acao
Copy link
Member

acao commented May 1, 2024

here is the proposal to remove ruby and ruby markdown block support!

#3592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants