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

Contributing a language mapping causes VS Code to activate your extension on that language #173992

Closed
mjbvz opened this issue Feb 9, 2023 · 4 comments · Fixed by #179287
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 9, 2023

Bug
The Python extension contributes the following language entry in its package.json:

     {
                "filenames": [
                    "Pipfile.lock"
                ],
                "id": "json"
            }

This seems to cause the python extension to be activated whenever a json file is opened, even though the extension does not provide any json language support

This was possibly caused by the move to automatic activation events

@joyceerhl joyceerhl added the bug Issue identified by VS Code Team member as probable bug label Feb 9, 2023
@joyceerhl joyceerhl added this to the February 2023 milestone Feb 9, 2023
@joyceerhl joyceerhl modified the milestones: February 2023, March 2023 Feb 22, 2023
@joyceerhl joyceerhl modified the milestones: March 2023, April 2023 Mar 20, 2023
@joyceerhl
Copy link
Collaborator

@alexdima I think my initial implementation of onLanguage implicit activation was perhaps too naive. There seem to be a few issues:

  • It's possible to have a language configuration extension that doesn't contribute any code, and we would now attempt to activate such an extension (this is a noop if there is no main/browser entrypoint in package.json, but results in unnecessary activation if all that's required is a language configuration)
  • the bigger issue is that an extension which contributes extensions, filenames, filenamePatterns, firstLine, or mimeTypes for a language will now get activated anytime the language appears
    • I think it's maybe reasonable to preserve the existing implicit activation behavior if an alias is defined
    • for all of the others, we shouldn't infer onLanguage, or we should perhaps keep track of the filenames/filenamePatterns etc and activate the extension with the language contribution matching the specified pattern?

I know of at least two extensions which are impacted by the current behavior

  • MakeCode
  • Python

@alexdima
Copy link
Member

alexdima commented Apr 5, 2023

I think it's maybe reasonable to preserve the existing implicit activation behavior if an alias is defined [...] for all of the others, we shouldn't infer onLanguage

👍 This makes good sense to me. We will infer onLanguage:X only for the one which is the "main" language definition, and the best evidence of that is the alias property. I wouldn't do anything beyond that (i.e. tracking filenames, patterns, etc.)

@joyceerhl
Copy link
Collaborator

infer onLanguage:X only for the one which is the "main" language definition

Would the presence of the configuration property be better evidence of a contribution being the main language definition?

@RedCMD
Copy link
Contributor

RedCMD commented Apr 5, 2023

injection based syntax highlighting can still have a configuration file

@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Apr 6, 2023
@mjbvz mjbvz added the verified Verification succeeded label Apr 25, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants