提交 bf904af7 编写于 作者: B Benjamin Pasero

clear user configured mime associations when updating

上级 7a48e16b
......@@ -22,10 +22,10 @@ export interface ITextMimeAssociation {
userConfigured?: boolean;
}
const registeredAssociations: ITextMimeAssociation[] = [];
let registeredAssociations: ITextMimeAssociation[] = [];
/**
* Associate a text mime to the registry
* Associate a text mime to the registry.
*/
export function registerTextMime(association: ITextMimeAssociation): void {
......@@ -58,6 +58,17 @@ export function registerTextMime(association: ITextMimeAssociation): void {
}
}
/**
* Clear text mimes from the registry.
*/
export function clearTextMimes(onlyUserConfigured?: boolean): void {
if (!onlyUserConfigured) {
registeredAssociations = [];
} else {
registeredAssociations = registeredAssociations.filter(a => !a.userConfigured);
}
}
/**
* Given a file, return the best matching mime type for it
*/
......
......@@ -39,6 +39,11 @@ export class FileAssociations implements IWorkbenchContribution {
}
private onConfigurationChange(configuration: IFilesConfiguration): void {
// Clear user configured mime associations
mime.clearTextMimes(true /* user configured */);
// Register based on settings
if (configuration.files && configuration.files.associations) {
Object.keys(configuration.files.associations).forEach(pattern => {
mime.registerTextMime({ mime: this.modeService.getMimeForMode(configuration.files.associations[pattern]), filepattern: pattern, userConfigured: true });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册