From 832f940906fd208feba98e3579ec1c96f4a9c21d Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 12 Jul 2018 08:27:43 +0200 Subject: [PATCH] fix #54052 --- .../electron-main/historyMainService.ts | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/vs/platform/history/electron-main/historyMainService.ts b/src/vs/platform/history/electron-main/historyMainService.ts index 8b8dbc2fe10..9b7309f7c55 100644 --- a/src/vs/platform/history/electron-main/historyMainService.ts +++ b/src/vs/platform/history/electron-main/historyMainService.ts @@ -62,29 +62,33 @@ export class HistoryMainService implements IHistoryMainService { const mru = this.getRecentlyOpened(); // Workspaces - workspaces.forEach(workspace => { - const isUntitledWorkspace = !isSingleFolderWorkspaceIdentifier(workspace) && this.workspacesMainService.isUntitledWorkspace(workspace); - if (isUntitledWorkspace) { - return; // only store saved workspaces - } - - mru.workspaces.unshift(workspace); - mru.workspaces = arrays.distinct(mru.workspaces, workspace => this.distinctFn(workspace)); - - // We do not add to recent documents here because on Windows we do this from a custom - // JumpList and on macOS we fill the recent documents in one go from all our data later. - }); + if (Array.isArray(workspaces)) { + workspaces.forEach(workspace => { + const isUntitledWorkspace = !isSingleFolderWorkspaceIdentifier(workspace) && this.workspacesMainService.isUntitledWorkspace(workspace); + if (isUntitledWorkspace) { + return; // only store saved workspaces + } + + mru.workspaces.unshift(workspace); + mru.workspaces = arrays.distinct(mru.workspaces, workspace => this.distinctFn(workspace)); + + // We do not add to recent documents here because on Windows we do this from a custom + // JumpList and on macOS we fill the recent documents in one go from all our data later. + }); + } // Files - files.forEach((path) => { - mru.files.unshift(path); - mru.files = arrays.distinct(mru.files, file => this.distinctFn(file)); - - // Add to recent documents (Windows only, macOS later) - if (isWindows) { - app.addRecentDocument(path); - } - }); + if (Array.isArray(files)) { + files.forEach((path) => { + mru.files.unshift(path); + mru.files = arrays.distinct(mru.files, file => this.distinctFn(file)); + + // Add to recent documents (Windows only, macOS later) + if (isWindows) { + app.addRecentDocument(path); + } + }); + } // Make sure its bounded mru.workspaces = mru.workspaces.slice(0, HistoryMainService.MAX_TOTAL_RECENT_ENTRIES); -- GitLab