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

[extension activation] Extension not activated on certain contribution points. #198295

Closed
ejgallego opened this issue Nov 15, 2023 · 4 comments
Closed
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@ejgallego
Copy link

ejgallego commented Nov 15, 2023

Dear VSCode devs,

this is a follow up to microsoft/vscode-discussions#901 , pinging you here as I believe there may be a bug, not sure

  • VS Code Version: 1.84.2
  • OS Version: Linux

Starting with VSCode 1.75 (I believe), when extensions contribute a language, they don't need to declare it in activation events. This works well for our extension .v files (cc: https://github.com/ejgallego/coq-lsp ), however, we'd also like our extension to be activated on certain markdown files ending in .mv.

This is the relevant part of our package.json

  "contributes": {
    "languages": [
      {
        "id": "markdown",
        "aliases": [
          "Markdown"
        ],
        "extensions": [
          ".mv"
        ]
      }
    ],

The situation here is strange:

  • if I activate the extension by other means, .mv files work fine and are recognized by our language server.
  • if I start from an empty VSCode workspace, and I open just a .mv file, the extension won't be activated.
  • The extension is activated normally by .v files, which are also declared on contributes.language

I'm not sure if this is intended or a bug, but given the recent changes to activation in 1.75 I thought I'd signal this to you folks.

Steps to reproduce

  1. build coq-lsp main branch, launch the extension in dev mode
  2. open an .mv file, (set examples as your workspace for example), the extension will be activated
  3. close VSCode, remove the onLanguage:markdown activation event
  4. repeat step 2, now the extension won't be activated.
@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.84.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@joyceerhl
Copy link
Contributor

joyceerhl commented Nov 20, 2023

We will only do an implicit activation for "main" language contributions, i.e. contributions that include the language configuration: #173992, #179287. This behavior is currently as designed, I'd suggest to declare a standard onLanguage: activation event for your scenario.

@joyceerhl joyceerhl closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2023
@joyceerhl joyceerhl added the *as-designed Described behavior is as designed label Nov 20, 2023
@ejgallego
Copy link
Author

Thanks a lot for the information @joyceerhl , I was not aware of the notion of this rule, it makes sense!

I'll actually play with the alias property too, as our language is really an alias, but so far the onLanguage plus the file selection rule is working as we desire as our extension is only activated for .mv files and not for .md files.

I checked the API docs, maybe this could be documented more directly?

I was looking here https://code.visualstudio.com/api/references/activation-events#onLanguage

If so let me know and I'll be happy to prepare a documentation PR.

@joyceerhl
Copy link
Contributor

Please feel free to send a PR, thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Jan 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

5 participants