Skip to content

Commit

Permalink
move focus check while converting
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jun 17, 2021
1 parent d95f6de commit 3f4baf4
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/vs/workbench/services/editor/browser/editorOverrideService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ export class EditorOverrideService extends Disposable implements IEditorOverride
// Read in the cache on statup
this.cache = new Set<string>(JSON.parse(this.storageService.get(EditorOverrideService.overrideCacheStorageID, StorageScope.GLOBAL, JSON.stringify([]))));
this.storageService.remove(EditorOverrideService.overrideCacheStorageID, StorageScope.GLOBAL);
this.hostService.hadLastFocus().then(hadLastFocus => {
if (!hadLastFocus) {
return;
}
this.convertOldAssociationFormat();
});
this.convertOldAssociationFormat();

this._register(this.storageService.onWillSaveState(() => {
// We want to store the glob patterns we would activate on, this allows us to know if we need to await the ext host on startup for opening a resource
Expand Down Expand Up @@ -188,20 +183,25 @@ export class EditorOverrideService extends Disposable implements IEditorOverride
}

private convertOldAssociationFormat(): void {
const rawAssociations = this.configurationService.getValue<EditorAssociations | { [fileNamePattern: string]: string }>(editorsAssociationsSettingId) || {};
// If it's not an array, then it's the new format
if (!Array.isArray(rawAssociations)) {
return;
}
let newSettingObject = Object.create(null);
// Make the correctly formatted object from the array and then set that object
for (const association of rawAssociations) {
if (association.filenamePattern) {
newSettingObject[association.filenamePattern] = association.viewType;
this.hostService.hadLastFocus().then(hadLastFocus => {
if (!hadLastFocus) {
return;
}
}
this.logService.info(`Migrating ${editorsAssociationsSettingId}`);
this.configurationService.updateValue(editorsAssociationsSettingId, newSettingObject);
const rawAssociations = this.configurationService.getValue<EditorAssociations | { [fileNamePattern: string]: string }>(editorsAssociationsSettingId) || {};
// If it's not an array, then it's the new format
if (!Array.isArray(rawAssociations)) {
return;
}
let newSettingObject = Object.create(null);
// Make the correctly formatted object from the array and then set that object
for (const association of rawAssociations) {
if (association.filenamePattern) {
newSettingObject[association.filenamePattern] = association.viewType;
}
}
this.logService.info(`Migrating ${editorsAssociationsSettingId}`);
this.configurationService.updateValue(editorsAssociationsSettingId, newSettingObject);
});
}

private getAllUserAssociations(): EditorAssociations {
Expand Down

0 comments on commit 3f4baf4

Please sign in to comment.