From 6fb9cc97dba998fac4df5f427e4a0ae03d21f4a8 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Wed, 12 Sep 2018 14:55:53 +0200 Subject: [PATCH] fix #35935 --- .../workbench/browser/parts/editor/editorActions.ts | 8 +++++++- src/vs/workbench/services/history/common/history.ts | 5 +++++ .../services/history/electron-browser/history.ts | 11 ++++++++++- src/vs/workbench/test/workbenchTestServices.ts | 3 +++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index 5c579fa655d..6dc35683bd4 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -1148,14 +1148,20 @@ export class ClearRecentFilesAction extends Action { constructor( id: string, label: string, - @IWindowsService private windowsService: IWindowsService + @IWindowsService private windowsService: IWindowsService, + @IHistoryService private historyService: IHistoryService ) { super(id, label); } run(): TPromise { + + // Clear global recently opened this.windowsService.clearRecentlyOpened(); + // Clear workspace specific recently opened + this.historyService.clearRecentlyOpened(); + return TPromise.as(false); } } diff --git a/src/vs/workbench/services/history/common/history.ts b/src/vs/workbench/services/history/common/history.ts index 0497fc99f37..b1237f677f6 100644 --- a/src/vs/workbench/services/history/common/history.ts +++ b/src/vs/workbench/services/history/common/history.ts @@ -51,6 +51,11 @@ export interface IHistoryService { */ clear(): void; + /** + * Clear list of recently opened editors. + */ + clearRecentlyOpened(): void; + /** * Get the entire history of opened editors. */ diff --git a/src/vs/workbench/services/history/electron-browser/history.ts b/src/vs/workbench/services/history/electron-browser/history.ts index 9991163267b..74ce63421eb 100644 --- a/src/vs/workbench/services/history/electron-browser/history.ts +++ b/src/vs/workbench/services/history/electron-browser/history.ts @@ -342,15 +342,24 @@ export class HistoryService extends Disposable implements IHistoryService { clear(): void { this.ensureHistoryLoaded(); + // Navigation (next, previous) this.index = -1; this.lastIndex = -1; this.stack.splice(0); - this.history = []; + + // Closed files this.recentlyClosedFiles = []; + // History + this.clearRecentlyOpened(); + this.updateContextKeys(); } + clearRecentlyOpened(): void { + this.history = []; + } + private updateContextKeys(): void { this.canNavigateBackContextKey.set(this.stack.length > 0 && this.index > 0); this.canNavigateForwardContextKey.set(this.stack.length > 0 && this.index < this.stack.length - 1); diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 2b5f18719b3..7b44d910963 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -354,6 +354,9 @@ export class TestHistoryService implements IHistoryService { public clear(): void { } + public clearRecentlyOpened(): void { + } + public getHistory(): (IEditorInput | IResourceInput)[] { return []; } -- GitLab