Allows settings to override language contributed bracket pair configurations.#134503
Conversation
|
@hediet Could you please fix the tests. |
d9336b0 to
df994ef
Compare
alexdima
left a comment
There was a problem hiding this comment.
I've left notes, we can also discuss.
| const openingBrackets = new Set</* openingText */ string>(); | ||
|
|
||
| for (const [openingText, closingText] of brackets) { | ||
| if (openingText === '' || closingText === '') { |
There was a problem hiding this comment.
I suggest to move the validation of brackets (i.e. that empty brackets are not allowed to ResolvedLanguageConfiguration). Otherwise, we would need to check for empty strings in all consumers of ResolvedLanguageConfiguration.
| return this._brackets; | ||
| } | ||
| function getCustomizedLanguageConfig(languageIdentifier: LanguageIdentifier, resource: URI | undefined, configurationService: IConfigurationService): LanguageConfiguration { | ||
| // TODO how should these keys be registered to the JSON schema? |
There was a problem hiding this comment.
You can define them together with the other non-editor options yet still editor.* settings at
| this.config = computeConfig(this.languageId, this.resource, this.configurationService, this.modeService); | ||
|
|
||
| this._register(this.configurationService.onDidChangeConfiguration((e) => { | ||
| this.update(); |
There was a problem hiding this comment.
if (!e.affectsConfiguration('editor')) {
return;
}There was a problem hiding this comment.
I do it like this now:
const customizedLanguageConfigKeys = {
brackets: 'editor.language.brackets',
colorizedBracketPairs: 'editor.language.colorizedBracketPairs'
};
// ...
const languageConfigKeys = new Set(Object.values(customizedLanguageConfigKeys));
const globalConfigChanged = e.change.keys.some((k) =>
languageConfigKeys.has(k)
);
const localConfigChanged = e.change.overrides
.filter(([overrideLangName, keys]) =>
keys.some((k) => languageConfigKeys.has(k))
)
.map(([overrideLangName]) => this.modeService.getLanguageIdentifier(overrideLangName));
if (globalConfigChanged) {
this.configurations.clear();
this.onDidChangeEmitter.fire(new LanguageConfigurationServiceChangeEvent(undefined));
} else {
for (const languageIdentifier of localConfigChanged) {
if (languageIdentifier) {
this.configurations.delete(languageIdentifier.id);
this.onDidChangeEmitter.fire(new LanguageConfigurationServiceChangeEvent(languageIdentifier));
}
}
}eeaa845 to
c3e8f38
Compare
10aef2b to
6650201
Compare
# Conflicts: # src/vs/editor/common/modes/languageConfigurationRegistry.ts
alexdima
left a comment
There was a problem hiding this comment.
Looks very good! Just one last problem I just noticed.
| import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; | ||
| import { Iterable } from 'vs/base/common/iterator'; | ||
| import { ResourceFileEdit } from 'vs/editor/browser/services/bulkEditService'; | ||
| import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/testLanguageConfigurationService'; |
There was a problem hiding this comment.
This is not a test, we should not use the TestLanguageConfigurationService here
This PR fixes #131412
TODOs: