Skip to content

Commit

Permalink
fix #35935
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 12, 2018
1 parent 51e471a commit 6fb9cc9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/vs/workbench/browser/parts/editor/editorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {

// Clear global recently opened
this.windowsService.clearRecentlyOpened();

// Clear workspace specific recently opened
this.historyService.clearRecentlyOpened();

return TPromise.as(false);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/services/history/common/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export interface IHistoryService {
*/
clear(): void;

/**
* Clear list of recently opened editors.
*/
clearRecentlyOpened(): void;

/**
* Get the entire history of opened editors.
*/
Expand Down
11 changes: 10 additions & 1 deletion src/vs/workbench/services/history/electron-browser/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/test/workbenchTestServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ export class TestHistoryService implements IHistoryService {
public clear(): void {
}

public clearRecentlyOpened(): void {
}

public getHistory(): (IEditorInput | IResourceInput)[] {
return [];
}
Expand Down

0 comments on commit 6fb9cc9

Please sign in to comment.