Skip to content

Default extensions overriding language configuration from user installed extensions #114684

Closed

Description

@PEZ

We have started to get reports from Calva users that Toggle Line Comments does the wrong thing: BetterThanTomorrow/calva#971

I think this stems from the default Clojure extension which sets lineComment to be a single ;. Calva changes this here: https://github.com/BetterThanTomorrow/calva/blob/published/src/calva-fmt/src/extension.ts#L24

This has been working for years, and still does for many people, but some days ago it stopped working for some. I also notice that the default extension has moved to its own repository, where there is now a PR to fix the line comment configuration: https://github.com/microsoft/vscode-clojure/pull/1

However, I think it is wrong that the default extension sometimes overrides an installed extension here. Then that API can't be trusted at all. I worry about what more configuration is now sometimes being overridden.

  • VSCode Version: 1.52.1
  • OS Version: N/A

Steps to Reproduce:

  1. Install Calva
  2. Open a *.clj file
  3. Issue the command Toggle Line Comment on an uncommented line

Expected: It gets commented with ;;

Actual: It gets commented with ;

Please let me know how I can assist in fixing this issue.

Does this issue occur when all extensions are disabled?: Not applicable

Activity

  1. alexdima commented on Jan 22, 2021

    @alexdima
    Member

    I am surprised that this ever worked reliably, it must have been some amazing timing luck.

    vscode-clojure defines a language configuration at https://github.com/microsoft/vscode-clojure/blob/d09c57202222618740e49f3e5b055f6ff16b3355/package.json#L30 .

    Language configuration file handling is implemented by waiting for the language to be first used (like embedded in another language like a markdown fence or a file using the language is opened) and then reading async the language configuration file and applying it. This is done here. Whenever the language configuration file finishes reading, it will go and configure the LanguageConfigurationRegistry here in pretty much the exact same way an extension calling setLanguageConfiguration configures it here.

    So deep down there is no difference between those two calls and basically those two calls are racing themselves and it is lucky that until now the call reading the descriptive file was always faster than the imperative call from your extension.

    If you want to be sure to overwrite the builtin language configuration, you can define your own language configuration file using:

    "contributes": {
        "languages": [
          {
            "id": "clojure",
            "configuration": "./language-configuration.json"
          }
        ]
    }
    

    But I also see how you would expect that the imperative call would "win" over the descriptive way, so maybe we can do something on our side to give a higher priority to the imperative call way of configuring languages.

    FYI: since a few days, onEnterRules can also be specified in JSON, so using the imperative way of configuring languages is no longer really necessary.

  2. PEZ commented on Jan 22, 2021

    @PEZ
    ContributorAuthor

    Thanks Alexandru Dima (@alexdima) ! This is great information. Calva has been relying on this luck for a very long time. 😄

    And yes, I actually choose to do it the imperative way very consciously, assuming it was the way to be sure I could override the defaults.

  3. locked and limited conversation to collaborators on Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions