Skip to content

Commit

Permalink
fix some todos (migration)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jul 5, 2016
1 parent a485c3a commit 375bd62
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 122 deletions.
51 changes: 1 addition & 50 deletions src/vs/workbench/browser/parts/editor/editor.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import {UntitledEditorInput} from 'vs/workbench/common/editor/untitledEditorInpu
import {ResourceEditorInput} from 'vs/workbench/common/editor/resourceEditorInput';
import {IInstantiationService, ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
import {KbExpr, IKeybindings, IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
import {KbExpr, IKeybindings} from 'vs/platform/keybinding/common/keybindingService';
import {TextDiffEditor} from 'vs/workbench/browser/parts/editor/textDiffEditor';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {IMessageService, Severity, CloseAction} from 'vs/platform/message/common/message';
import {BinaryResourceDiffEditor} from 'vs/workbench/browser/parts/editor/binaryDiffEditor';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import {IConfigurationRegistry, Extensions as ConfigurationExtensions} from 'vs/platform/configuration/common/configurationRegistry';
Expand Down Expand Up @@ -403,52 +402,4 @@ configurationRegistry.registerConfiguration({
'description': nls.localize('editorOpenPositioning', "Controls where editors open. Select 'left' or 'right' to open editors to the left or right of the current active one. Select 'first' or 'last' to open editors independently from the currently active one.")
}
}
});

// TODO@Ben remove me next version

const mapDeprecatedCommands = {
'workbench.action.focusFirstEditor': 'workbench.action.focusFirstEditorGroup',
'workbench.action.focusSecondEditor': 'workbench.action.focusSecondEditorGroup',
'workbench.action.focusThirdEditor': 'workbench.action.focusThirdEditorGroup',
'workbench.action.focusLeftEditor': 'workbench.action.focusPreviousGroup',
'workbench.action.focusRightEditor': 'workbench.action.focusNextGroup',
'workbench.action.moveActiveEditorLeft': 'workbench.action.moveActiveEditorGroupLeft',
'workbench.action.moveActiveEditorRight': 'workbench.action.moveActiveEditorGroupRight',
'workbench.action.openPreviousEditor': 'workbench.action.openPreviousEditorFromHistory',
'workbench.files.action.addToWorkingFiles': 'workbench.action.keepEditor',
'workbench.files.action.closeAllFiles': 'workbench.action.closeAllEditors',
'workbench.files.action.closeFile': 'workbench.action.closeActiveEditor',
'workbench.files.action.closeOtherFiles': 'workbench.action.closeOtherEditors',
'workbench.files.action.focusWorkingFiles': 'workbench.files.action.focusOpenEditorsView',
'workbench.files.action.openNextWorkingFile': 'workbench.action.nextEditor',
'workbench.files.action.openPreviousWorkingFile': 'workbench.action.previousEditor',
'workbench.files.action.reopenClosedFile': 'workbench.action.reopenClosedEditor',
'workbench.files.action.workingFilesPicker': 'workbench.action.showAllEditors',
'workbench.action.cycleEditor': 'workbench.action.navigateEditorGroups'
};

Object.keys(mapDeprecatedCommands).forEach(deprecatedCommandId => {
const newCommandId = mapDeprecatedCommands[deprecatedCommandId];

KeybindingsRegistry.registerCommandDesc({
id: deprecatedCommandId,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
handler(accessor: ServicesAccessor) {
const messageService = accessor.get(IMessageService);
const keybindingService = accessor.get(IKeybindingService);

messageService.show(Severity.Warning, {
message: nls.localize('commandDeprecated', "Command **{0}** is now deprecated. You can use **{1}** instead", deprecatedCommandId, newCommandId),
actions: [
CloseAction,
new Action('openKeybindings', nls.localize('openKeybindings', "Configure Keyboard Shortcuts"), null, true, () => {
return keybindingService.executeCommand('workbench.action.openGlobalKeybindings');
})
]
});
},
when: undefined,
primary: undefined
});
});
50 changes: 0 additions & 50 deletions src/vs/workbench/common/editor/editorStacksModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,6 @@ export class EditorStacksModel implements IEditorStacksModel {
if (modelRaw) {
const serialized: ISerializedEditorStacksModel = JSON.parse(modelRaw);

// TODO@Ben remove this once stacks are stable; prevent bad stored state
const invalidId = this.doValidate(serialized);
if (invalidId) {
console.warn(`Ignoring invalid stacks model (Error code: ${invalidId}): ${JSON.stringify(serialized)}`);
Expand All @@ -1002,55 +1001,6 @@ export class EditorStacksModel implements IEditorStacksModel {

this._groups = serialized.groups.map(s => this.doCreateGroup(s));
this._activeGroup = this._groups[serialized.active];
} else {
this.migrate();
}
}

// TODO@Ben migration
private migrate(): void {
const LEGACY_EDITOR_STATE_STORAGE_KEY = 'memento/workbench.parts.editor';
const legacyModelRaw = this.storageService.get(LEGACY_EDITOR_STATE_STORAGE_KEY, StorageScope.WORKSPACE);
if (legacyModelRaw) {
try {
const legacyModel = JSON.parse(legacyModelRaw);
const state = legacyModel['editorpart.editorState'];
const editorsRaw: { inputId: string; inputValue: string }[] = state.editors;

const registry = Registry.as<IEditorRegistry>(Extensions.Editors);
const editors = editorsRaw.map(editorRaw => {
const factory = registry.getEditorInputFactory(editorRaw.inputId);
if (factory) {
return factory.deserialize(this.instantiationService, editorRaw.inputValue);
}

return null;
}).filter(editor => !!editor);

if (editors.length > 0) {
const leftGroup = this.openGroup('', true);
leftGroup.openEditor(editors[0], { active: true, pinned: true });
}

if (editors.length > 1) {
const centerGroup = this.openGroup('', true);
centerGroup.openEditor(editors[1], { active: true, pinned: true });
}

if (editors.length > 2) {
const rightGroup = this.openGroup('', true);
rightGroup.openEditor(editors[2], { active: true, pinned: true });
}

this.storageService.remove(LEGACY_EDITOR_STATE_STORAGE_KEY, StorageScope.WORKSPACE);
} catch (error) {
console.warn('Unable to migrate previous editor state', error, legacyModelRaw);

// Reset
this._groups = [];
this._activeGroup = void 0;
this.groupToIdentifier = Object.create(null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/edito
import {IModeService} from 'vs/editor/common/services/modeService';
import {IThemeService} from 'vs/workbench/services/themes/common/themeService';

const LEGACY_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'editorViewState'; // TODO@Ben migration
const TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'textEditorViewState';

interface ITextEditorViewState {
Expand Down Expand Up @@ -297,12 +296,6 @@ export class TextFileEditor extends BaseTextEditor {
}
}

// TODO@Ben migration
const legacyEditorViewStateMemento = memento[LEGACY_EDITOR_VIEW_STATE_PREFERENCE_KEY];
if (legacyEditorViewStateMemento) {
return legacyEditorViewStateMemento[key];
}

return null;
}

Expand Down
15 changes: 0 additions & 15 deletions src/vs/workbench/services/history/browser/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,21 +626,6 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
let entriesRaw = this.storageService.get(HistoryService.STORAGE_KEY, StorageScope.WORKSPACE);
if (entriesRaw) {
entries = JSON.parse(entriesRaw);
} else {
// TODO@Ben migration
try {
const oldMementoRaw = this.storageService.get('memento/workbench.component.quickopen', StorageScope.WORKSPACE);
if (oldMementoRaw) {
const oldMemento = JSON.parse(oldMementoRaw);
const oldEntries = oldMemento['quickopen.editorhistory'].entries;

if (oldEntries) {
entries = oldEntries;
}
}
} catch (error) {
console.error(error);
}
}

this.history = entries.map(entry => {
Expand Down

0 comments on commit 375bd62

Please sign in to comment.