diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 328e3a99ccd..0e966914f85 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -511,7 +511,8 @@ export class VSCodeMenu { if (folders.length || files.length) { openRecentMenu.append(__separator__()); - openRecentMenu.append(new MenuItem(this.likeAction('clearRecentlyOpened', { label: mnemonicLabel(nls.localize({ key: 'miClearItems', comment: ['&& denotes a mnemonic'] }, "&&Clear Items")), click: () => this.windowsService.clearRecentPathsList() }, false))); + //workbench.action.clearRecentItems + openRecentMenu.append(this.createMenuItem(nls.localize({ key: 'miClearRecentOpen', comment: ['&& denotes a mnemonic'] }, "&&Clear Items"), 'workbench.action.clearRecentItems')); } } diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index 12e2783f1b0..f4c7719f18e 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -30,6 +30,7 @@ export interface IWindowsService { setRepresentedFilename(windowId: number, fileName: string): TPromise; addToRecentlyOpen(paths: { path: string, isFile?: boolean }[]): TPromise; removeFromRecentlyOpen(paths: string[]): TPromise; + clearRecentPathsList(): TPromise; getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }>; focusWindow(windowId: number): TPromise; isMaximized(windowId: number): TPromise; diff --git a/src/vs/platform/windows/common/windowsIpc.ts b/src/vs/platform/windows/common/windowsIpc.ts index a4aadc3cec3..6cbd4dfc269 100644 --- a/src/vs/platform/windows/common/windowsIpc.ts +++ b/src/vs/platform/windows/common/windowsIpc.ts @@ -24,6 +24,7 @@ export interface IWindowsChannel extends IChannel { call(command: 'setRepresentedFilename', arg: [number, string]): TPromise; call(command: 'addToRecentlyOpen', arg: { path: string, isFile?: boolean }[]): TPromise; call(command: 'removeFromRecentlyOpen', arg: string[]): TPromise; + call(command: 'clearRecentPathsList'): TPromise; call(command: 'getRecentlyOpen', arg: number): TPromise<{ files: string[]; folders: string[]; }>; call(command: 'focusWindow', arg: number): TPromise; call(command: 'isMaximized', arg: number): TPromise; @@ -72,6 +73,7 @@ export class WindowsChannel implements IWindowsChannel { case 'setRepresentedFilename': return this.service.setRepresentedFilename(arg[0], arg[1]); case 'addToRecentlyOpen': return this.service.addToRecentlyOpen(arg); case 'removeFromRecentlyOpen': return this.service.removeFromRecentlyOpen(arg); + case 'clearRecentPathsList': return this.service.clearRecentPathsList(); case 'getRecentlyOpen': return this.service.getRecentlyOpen(arg); case 'focusWindow': return this.service.focusWindow(arg); case 'isMaximized': return this.service.isMaximized(arg); @@ -153,6 +155,10 @@ export class WindowsChannelClient implements IWindowsService { return this.channel.call('removeFromRecentlyOpen', paths); } + clearRecentPathsList(): TPromise { + return this.channel.call('clearRecentPathsList'); + } + getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> { return this.channel.call('getRecentlyOpen', windowId); } diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index 1aa25788815..bf2afc56a5e 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -140,6 +140,11 @@ export class WindowsService implements IWindowsService, IDisposable { return TPromise.as(null); } + clearRecentPathsList(): TPromise { + this.windowsMainService.clearRecentPathsList(); + return TPromise.as(null); + } + getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> { const vscodeWindow = this.windowsMainService.getWindowById(windowId); diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index 1ac024c3c3f..666b6650a48 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -34,7 +34,7 @@ import { NavigateBetweenGroupsAction, FocusActiveGroupAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInGroupOneAction, toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, CloseRightEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, ReopenClosedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction, NAVIGATE_IN_GROUP_ONE_PREFIX, OpenPreviousEditorFromHistoryAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction, ShowEditorsInGroupTwoAction, MoveEditorRightInGroupAction, OpenNextEditorInGroup, OpenPreviousEditorInGroup, - NAVIGATE_IN_GROUP_TWO_PREFIX, ShowEditorsInGroupThreeAction, NAVIGATE_IN_GROUP_THREE_PREFIX, FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToPreviousGroupAction, MoveEditorToNextGroupAction, MoveEditorLeftInGroupAction + NAVIGATE_IN_GROUP_TWO_PREFIX, ShowEditorsInGroupThreeAction, NAVIGATE_IN_GROUP_THREE_PREFIX, FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToPreviousGroupAction, MoveEditorToNextGroupAction, MoveEditorLeftInGroupAction, ClearRecentItemsAction } from 'vs/workbench/browser/parts/editor/editorActions'; import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands'; @@ -323,6 +323,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(ShowEditorsInGroupThre registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextEditor, OpenNextEditor.ID, OpenNextEditor.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.PageDown, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.RightArrow, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET] } }), 'View: Open Next Editor', category); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousEditor, OpenPreviousEditor.ID, OpenPreviousEditor.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.PageUp, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.LeftArrow, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET] } }), 'View: Open Previous Editor', category); registry.registerWorkbenchAction(new SyncActionDescriptor(ReopenClosedEditorAction, ReopenClosedEditorAction.ID, ReopenClosedEditorAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_T }), 'View: Reopen Closed Editor', category); +registry.registerWorkbenchAction(new SyncActionDescriptor(ClearRecentItemsAction, ClearRecentItemsAction.ID, ClearRecentItemsAction.LABEL), 'View: Clear Items', category); registry.registerWorkbenchAction(new SyncActionDescriptor(KeepEditorAction, KeepEditorAction.ID, KeepEditorAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.Enter) }), 'View: Keep Editor', category); registry.registerWorkbenchAction(new SyncActionDescriptor(CloseAllEditorsAction, CloseAllEditorsAction.ID, CloseAllEditorsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_W) }), 'View: Close All Editors', category); registry.registerWorkbenchAction(new SyncActionDescriptor(CloseLeftEditorsInGroupAction, CloseLeftEditorsInGroupAction.ID, CloseLeftEditorsInGroupAction.LABEL), 'View: Close Editors to the Left', category); diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index 40d0d470dde..b3fb31e274b 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -22,6 +22,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IEditorGroupService, GroupArrangement } from 'vs/workbench/services/group/common/groupService'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; +import { IWindowsService } from 'vs/platform/windows/common/windows'; export class SplitEditorAction extends Action { @@ -1114,6 +1115,26 @@ export class ReopenClosedEditorAction extends Action { } } +export class ClearRecentItemsAction extends Action { + + public static ID = 'workbench.action.clearRecentItems'; + public static LABEL = nls.localize('clearRecentItems', "Clear Recent"); + + constructor( + id: string, + label: string, + @IWindowsService private windowsService: IWindowsService + ) { + super(id, label); + } + + public run(): TPromise { + this.windowsService.clearRecentPathsList(); + + return TPromise.as(false); + } +} + export const NAVIGATE_IN_GROUP_ONE_PREFIX = 'edt one '; export class ShowEditorsInGroupOneAction extends QuickOpenAction { diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 586b7623068..bd99e623c01 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -914,6 +914,9 @@ export class TestWindowsService implements IWindowsService { removeFromRecentlyOpen(paths: string[]): TPromise { return TPromise.as(void 0); } + clearRecentPathsList(): TPromise { + return TPromise.as(void 0); + } getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> { return TPromise.as(void 0); }