From bd289999dd2dfca4e840e15cb59c7b588e7fcf0b Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Fri, 8 Mar 2019 17:02:23 +0100 Subject: [PATCH] don't store empty label list --- .../history/electron-main/historyStorage.ts | 18 +++++++++++++++--- .../windows/electron-browser/windowService.ts | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/history/electron-main/historyStorage.ts b/src/vs/platform/history/electron-main/historyStorage.ts index 365d31d4369..b46e6b2cdae 100644 --- a/src/vs/platform/history/electron-main/historyStorage.ts +++ b/src/vs/platform/history/electron-main/historyStorage.ts @@ -81,20 +81,32 @@ export function restoreRecentlyOpened(data: RecentlyOpenedStorageData | undefine } export function toStoreData(recents: IRecentlyOpened): RecentlyOpenedStorageData { - const serialized: ISerializedRecentlyOpened = { workspaces3: [], files2: [], workspaceLabels: [], fileLabels: [] }; + const serialized: ISerializedRecentlyOpened = { workspaces3: [], files2: [] }; + let hasLabel = false; + const workspaceLabels: (string | null)[] = []; for (const recent of recents.workspaces) { if (isRecentFolder(recent)) { serialized.workspaces3.push(recent.folderUri.toString()); } else { serialized.workspaces3.push({ id: recent.workspace.id, configURIPath: recent.workspace.configPath.toString() }); } - serialized.workspaceLabels.push(recent.label || null); + workspaceLabels.push(recent.label || null); + hasLabel = hasLabel || !!recent.label; + } + if (hasLabel) { + serialized.workspaceLabels = workspaceLabels; } + hasLabel = false; + const fileLabels: (string | null)[] = []; for (const recent of recents.files) { serialized.files2.push(recent.fileUri.toString()); - serialized.fileLabels.push(recent.label || null); + fileLabels.push(recent.label || null); + hasLabel = hasLabel || !!recent.label; + } + if (hasLabel) { + serialized.fileLabels = fileLabels; } return serialized; diff --git a/src/vs/platform/windows/electron-browser/windowService.ts b/src/vs/platform/windows/electron-browser/windowService.ts index 46e74f4298d..5ba6a4e345f 100644 --- a/src/vs/platform/windows/electron-browser/windowService.ts +++ b/src/vs/platform/windows/electron-browser/windowService.ts @@ -100,7 +100,7 @@ export class WindowService extends Disposable implements IWindowService { openWindow(uris: IURIToOpen[], options?: IOpenSettings): Promise { if (!!this.configuration.remoteAuthority) { - uris.forEach(u => u.label = u.label || this.getRecentLabel(u, options && options.forceOpenWorkspaceAsFile)); + uris.forEach(u => u.label = u.label || this.getRecentLabel(u, !!(options && options.forceOpenWorkspaceAsFile))); } return this.windowsService.openWindow(this.windowId, uris, options); }