microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.16k stars 28.84k forks source link

implicit onLanguage extension activation event not happening if language is declared, but has no language-configuration.json #204333

Open iliazeus opened 8 months ago

iliazeus commented 8 months ago

Does this issue occur when all extensions are disabled?: N/A

Looks like this change may have been intentional - though made specifically to accomodate the Python extension? It broke mine though, and possibly others. Either way, it should at least be properly documented both in the activation events section of the docs, and in the VSCode changelog.

Steps to Reproduce:

  1. Install the 1.1.6 version of the ANSI Colors extension (iliazeus/vscode-ansi, source code here) - newer versions have a dummy language-configuration.json to avoid this bug.
  2. Navigate to a file that should now be recognized as "ANSI text" language (like this one in the extension repo - if copy-pasting, remember that it has invisible characters!).

Expected: text is colored as a result of the extension being activated

Actual: extension is not activated, no colors show up

VSCodeTriageBot commented 8 months ago

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

Happy Coding!

iliazeus commented 8 months ago

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

Yes, this issue remains; I tested it on 1.86.0 and on all 1.85.x.

RedCMD commented 8 months ago

I would just explicitly put the onLanguage in "activationEvents" (removing the dummy language-configuration.json) as VSCode doesn't complain if the "configuration" isn't found (haven't tested publishing tho)

alexdima commented 3 months ago

I would just explicitly put the onLanguage in "activationEvents"

:+1: for this

This is a bit complex. A language can be contributed by multiple extensions, usually one extension contributes the language, but other extensiosn can contribute additional file extensions, or additional filenames which should be mapped to that language. We added the implicit activation events retroactively (they were not there on day 1), so we want to avoid activating an extension for that particular language if it is not the main extension... I hope this explains the behavior you're observing.

Would you be willing to help and contribute a PR to https://github.com/microsoft/vscode-docs/blob/main/api/references/activation-events.md ?