Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@bamarsha
Copy link
Contributor

@bamarsha bamarsha commented Jul 8, 2020

The .v.template file extension for the Q# grammar file means that GitHub Linguist did not recognize it, which means that syntax highlighting for Q# cannot be added to GitHub (see issue #504 from @JakuJ). I'm removing the #SEMVER_VERSION# template variable from the grammar file so the template extension can be removed. Here are my reasons for removing it:

  • The starter file for VS Code extension grammars does not include a version property.
  • Syntax highlighting in the VS Code extension seems to work fine without the version property.
  • The version property is not actually part of the tmlanguage.json schema that the file uses.
  • The version number is already specified for the extension itself; including it in the grammar seems redundant.

Since I don't know what the original reason was for including the version number, I'm not sure if this will break something that I haven't thought of. @bettinaheim @ricardo-espinoza?

Closes #504.

@tcNickolas
Copy link
Contributor

I think I might've been the first person to put that field in this file, and that was back in 2017... One thing that might break (I can't find a paper trail for this so it's from memory) is that VS is really good at caching the grammars (in %localappdata%\Microsoft\VisualStudio\), so it only updates the cached grammar files if the file version is newer, otherwise the user will be stuck with the highlight they get from the 1st installation. (We're sharing this file for VS and VS Code both.) I'm not sure this behavior is still there, or that the user is not stuck with the first highlight they get even with versions - probably needs to be checked.

Copy link
Contributor

@JakuJ JakuJ left a comment

Choose a reason for hiding this comment

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

There seems to be an issue with the "copyright" field as well.

bamarsha and others added 2 commits July 9, 2020 15:16
Co-authored-by: Jakub Janaszkiewicz <janaszkiewicz.jakub@gmail.com>
@bamarsha
Copy link
Contributor Author

bamarsha commented Jul 10, 2020

I think I might've been the first person to put that field in this file, and that was back in 2017... One thing that might break (I can't find a paper trail for this so it's from memory) is that VS is really good at caching the grammars (in %localappdata%\Microsoft\VisualStudio\), so it only updates the cached grammar files if the file version is newer, otherwise the user will be stuck with the highlight they get from the 1st installation. (We're sharing this file for VS and VS Code both.) I'm not sure this behavior is still there, or that the user is not stuck with the first highlight they get even with versions - probably needs to be checked.

I tried this out:

  1. Build VSIX and install it.
  2. Open Q# file to look at syntax highlighting.
  3. Change qsharp.tmLanguage.json (I added hello as a new highlighted keyword).
  4. Update version number in source.extension.vsixmanifest, rebuild VSIX and install it.
  5. Open Q# file and check that the changes were applied (hello was now highlighted blue).

It worked for me without a version property in the grammar file. I am assuming that whatever caching Visual Studio does is based on the extension version rather than the grammar file version property. This was with Visual Studio 2019 (16.6.3).

@bamarsha bamarsha requested a review from tcNickolas July 10, 2020 20:49
@bamarsha bamarsha changed the title Remove version number and template extension from Q# grammar file Remove version and copyright properties from Q# grammar file Jul 10, 2020
Copy link
Contributor

@tcNickolas tcNickolas left a comment

Choose a reason for hiding this comment

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

I hope that means that VS team changed the caching behavior since 2017 when I last looked into it :-)

That was my only concern, so looks good!

@bamarsha bamarsha merged commit 84b7a64 into master Jul 11, 2020
@bamarsha bamarsha deleted the samarsha/tmlanguage branch July 11, 2020 04:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Official Q# syntax file not recognized by GitHub's Linguist

4 participants