Change:
) { } } <del> export class LanguageConfigurationRegistryImpl { </del> <ins> class LanguageConfigurationEntry { constructor( public readonly configuration: LanguageConfiguration, public readonly priority: number, public readonly order: number ) { } </ins> <del> private readonly _entries = new Map<LanguageId, RichEditSupport | undefined>(); </del> <ins> public static cmp(a: LanguageConfigurationEntry, b: LanguageConfigurationEntry) { if (a.priority === b.priority) { // higher order last return a.order - b.order; } // higher priority last return a.priority - b.priority; } } </ins> <del> private readonly _onDidChange = new Emitter<LanguageConfigurationChangeEvent>(); public readonly onDidChange: Event<LanguageConfigurationChangeEvent> = this._onDidChange.event; </del> <ins> class LanguageConfigurationEntries { </ins> <del> public register(languageIdentifier: LanguageIdentifier, configuration: LanguageConfiguration): IDisposable { let previous = this._getRichEditSupport(languageIdentifier.id); let current = new RichEditSupport(languageIdentifier, previous, configuration); this._entries.set(languageIdentifier.id, current); this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier)); </del> <ins> private readonly _entries: LanguageConfigurationEntry[]; private _order: number; private _resolved: RichEditSupport | null = null; constructor( public readonly languageIdentifier: LanguageIdentifier ) { this._entries = []; this._order = 0; this._resolved = null; } public register(configuration: LanguageConfiguration, priority: number): IDisposable { const entry = new LanguageConfigurationEntry(configuration, priority, ++this._order); this._entries.push(entry); this._resolved = null; </ins> return toDisposable(() => { <del> if (this._entries.get(languageIdentifier.id) === current) { this._entries.set(languageIdentifier.id, previous); this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier)); </del> <ins> for (let i = 0; i < this._entries.length; i++) { if (this._entries[i] === entry) { this._entries.splice(i, 1); this._resolved = null; break; } </ins> } }); } <del> private _getRichEditSupport(languageId: LanguageId): RichEditSupport | undefined { return this._entries.get(languageId); </del> <ins> public getRichEditSupport(): RichEditSupport | null { if (!this._resolved) { const config = this._resolve(); if (config) { this._resolved = new RichEditSupport(this.languageIdentifier, config); } } return this._resolved; </ins> } <del> public getIndentationRules(languageId: LanguageId) { const value = this._entries.get(languageId); if (!value) { </del> <ins> private _resolve(): LanguageConfiguration | null { if (this._entries.length === 0) { </ins> return null; } <ins> this._entries.sort(LanguageConfigurationEntry.cmp); const result: LanguageConfiguration = {}; for (const entry of this._entries) { const conf = entry.configuration; result.comments = conf.comments || result.comments; result.brackets = conf.brackets || result.brackets; result.wordPattern = conf.wordPattern || result.wordPattern; result.indentationRules = conf.indentationRules || result.indentationRules; result.onEnterRules = conf.onEnterRules || result.onEnterRules; result.autoClosingPairs = conf.autoClosingPairs || result.autoClosingPairs; result.surroundingPairs = conf.surroundingPairs || result.surroundingPairs; result.autoCloseBefore = conf.autoCloseBefore || result.autoCloseBefore; result.folding = conf.folding || result.folding; result.__electricCharacterSupport = conf.__electricCharacterSupport || result.__electricCharacterSupport; } return result; } } </ins> <del> return value.indentationRules || null; </del> <ins> export class LanguageConfigurationRegistryImpl { private readonly _entries2 = new Map<LanguageId, LanguageConfigurationEntries>(); private readonly _onDidChange = new Emitter<LanguageConfigurationChangeEvent>(); public readonly onDidChange: Event<LanguageConfigurationChangeEvent> = this._onDidChange.event; /** * @param priority Use a higher number for higher priority */ public register(languageIdentifier: LanguageIdentifier, configuration: LanguageConfiguration, priority: number = 0): IDisposable { let entries = this._entries2.get(languageIdentifier.id); if (!entries) { entries = new LanguageConfigurationEntries(languageIdentifier); this._entries2.set(languageIdentifier.id, entries); } const disposable = entries.register(configuration, priority); this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier)); return toDisposable(() => { disposable.dispose(); this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier)); }); } private _getRichEditSupport(languageId: LanguageId): RichEditSupport | null { const entries = this._entries2.get(languageId); return entries ? entries.getRichEditSupport() : null; } public getIndentationRules(languageId: LanguageId): IndentationRule | null { const value = this._getRichEditSupport(languageId); return value ? value.indentationRules || null : null; </ins> } // begin electricCharacter

Discussion:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Please search existing issues to avoid creating duplicates. --<!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: --We have started to get reports from users that Toggle Line Comments does the wrong thing: I think this stems from the default Clojure extension which sets to be a single . Calva changes this here: 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: 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. <!-- Use Help Report Issue to prefill these. --- VSCode Version: 1.52.1 OS Version: N/A Steps to Reproduce: Calva a file 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. <!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Not applicable
I am surprised that this ever worked reliably, it must have been some amazing timing luck. defines a language configuration at . 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 . Whenever the language configuration file finishes reading, it will go and configure the in pretty much the exact same way an extension calling configures it . 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: 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.
Thanks !

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.