Cleanup legacy recently opened code. Fixes #122623

This commit is contained in:
Martin Aeschlimann 2022-04-06 13:13:58 +02:00
parent 14c8d53371
commit 61b860aab7
No known key found for this signature in database
GPG key ID: 2609A01E695523E3
2 changed files with 0 additions and 60 deletions

View file

@ -297,13 +297,6 @@ interface ISerializedRecentFile {
readonly remoteAuthority?: string;
}
interface ISerializedRecentlyOpenedLegacy {
readonly workspaces3: Array<{ id: string; configURIPath: string } | string>; // workspace or URI.toString() // added in 1.32
readonly workspaceLabels?: Array<string | null>; // added in 1.33
readonly files2: string[]; // files as URI.toString() // added in 1.32
readonly fileLabels?: Array<string | null>; // added in 1.33
}
interface ISerializedRecentlyOpened {
readonly entries: Array<ISerializedRecentWorkspace | ISerializedRecentFolder | ISerializedRecentFile>; // since 1.55
}
@ -349,26 +342,6 @@ export function restoreRecentlyOpened(data: RecentlyOpenedStorageData | undefine
result.files.push({ label, remoteAuthority, fileUri: URI.parse(entry.fileUri) });
}
});
} else {
const storedRecents2 = data as ISerializedRecentlyOpenedLegacy;
if (Array.isArray(storedRecents2.workspaces3)) {
restoreGracefully(storedRecents2.workspaces3, (workspace, i) => {
const label: string | undefined = (Array.isArray(storedRecents2.workspaceLabels) && storedRecents2.workspaceLabels[i]) || undefined;
if (typeof workspace === 'object' && typeof workspace.id === 'string' && typeof workspace.configURIPath === 'string') {
result.workspaces.push({ label, workspace: { id: workspace.id, configPath: URI.parse(workspace.configURIPath) } });
} else if (typeof workspace === 'string') {
result.workspaces.push({ label, folderUri: URI.parse(workspace) });
}
});
}
if (Array.isArray(storedRecents2.files2)) {
restoreGracefully(storedRecents2.files2, (file, i) => {
const label: string | undefined = (Array.isArray(storedRecents2.fileLabels) && storedRecents2.fileLabels[i]) || undefined;
if (typeof file === 'string') {
result.files.push({ label, fileUri: URI.parse(file) });
}
});
}
}
}

View file

@ -107,39 +107,6 @@ suite('History Storage', () => {
assertRestoring(ro, 'authority');
});
test('open 1_33', () => {
const v1_33 = `{
"workspaces3": [
{
"id": "53b714b46ef1a2d4346568b4f591028c",
"configURIPath": "file:///home/user/workspaces/testing/custom.code-workspace"
},
"file:///home/user/workspaces/testing/folding"
],
"files2": [
"file:///home/user/.config/code-oss-dev/storage.json"
],
"workspaceLabels": [
null,
"abc"
],
"fileLabels": [
"def"
]
}`;
let windowsState = restoreRecentlyOpened(JSON.parse(v1_33), new NullLogService());
let expected: IRecentlyOpened = {
files: [{ label: 'def', fileUri: URI.parse('file:///home/user/.config/code-oss-dev/storage.json') }],
workspaces: [
{ workspace: { id: '53b714b46ef1a2d4346568b4f591028c', configPath: URI.parse('file:///home/user/workspaces/testing/custom.code-workspace') } },
{ label: 'abc', folderUri: URI.parse('file:///home/user/workspaces/testing/folding') }
]
};
assertEqualRecentlyOpened(windowsState, expected, 'v1_33');
});
test('open 1_55', () => {
const v1_55 = `{
"entries": [