Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #22768 #23049

Merged
merged 3 commits into from
Mar 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ 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)));
openRecentMenu.append(this.createMenuItem(nls.localize({ key: 'miClearRecentOpen', comment: ['&& denotes a mnemonic'] }, "&&Clear Recent Files"), 'workbench.action.clearRecentFiles'));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/windows/common/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IWindowsService {
setRepresentedFilename(windowId: number, fileName: string): TPromise<void>;
addToRecentlyOpen(paths: { path: string, isFile?: boolean }[]): TPromise<void>;
removeFromRecentlyOpen(paths: string[]): TPromise<void>;
clearRecentPathsList(): TPromise<void>;
getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }>;
focusWindow(windowId: number): TPromise<void>;
isMaximized(windowId: number): TPromise<boolean>;
Expand Down
6 changes: 6 additions & 0 deletions src/vs/platform/windows/common/windowsIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IWindowsChannel extends IChannel {
call(command: 'setRepresentedFilename', arg: [number, string]): TPromise<void>;
call(command: 'addToRecentlyOpen', arg: { path: string, isFile?: boolean }[]): TPromise<void>;
call(command: 'removeFromRecentlyOpen', arg: string[]): TPromise<void>;
call(command: 'clearRecentPathsList'): TPromise<void>;
call(command: 'getRecentlyOpen', arg: number): TPromise<{ files: string[]; folders: string[]; }>;
call(command: 'focusWindow', arg: number): TPromise<void>;
call(command: 'isMaximized', arg: number): TPromise<boolean>;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -153,6 +155,10 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('removeFromRecentlyOpen', paths);
}

clearRecentPathsList(): TPromise<void> {
return this.channel.call('clearRecentPathsList');
}

getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
return this.channel.call('getRecentlyOpen', windowId);
}
Expand Down
5 changes: 5 additions & 0 deletions src/vs/platform/windows/electron-main/windowsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ export class WindowsService implements IWindowsService, IDisposable {
return TPromise.as(null);
}

clearRecentPathsList(): TPromise<void> {
this.windowsMainService.clearRecentPathsList();
return TPromise.as(null);
}

getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
const vscodeWindow = this.windowsMainService.getWindowById(windowId);

Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/browser/parts/editor/editor.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, ClearRecentFilesAction
} from 'vs/workbench/browser/parts/editor/editorActions';
import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands';

Expand Down Expand Up @@ -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(ClearRecentFilesAction, ClearRecentFilesAction.ID, ClearRecentFilesAction.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);
Expand Down
21 changes: 21 additions & 0 deletions src/vs/workbench/browser/parts/editor/editorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -1114,6 +1115,26 @@ export class ReopenClosedEditorAction extends Action {
}
}

export class ClearRecentFilesAction extends Action {

public static ID = 'workbench.action.clearRecentFiles';
public static LABEL = nls.localize('clearRecentFiles', "Clear Recent Files");

constructor(
id: string,
label: string,
@IWindowsService private windowsService: IWindowsService
) {
super(id, label);
}

public run(): TPromise<any> {
this.windowsService.clearRecentPathsList();

return TPromise.as(false);
}
}

export const NAVIGATE_IN_GROUP_ONE_PREFIX = 'edt one ';

export class ShowEditorsInGroupOneAction extends QuickOpenAction {
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 @@ -914,6 +914,9 @@ export class TestWindowsService implements IWindowsService {
removeFromRecentlyOpen(paths: string[]): TPromise<void> {
return TPromise.as(void 0);
}
clearRecentPathsList(): TPromise<void> {
return TPromise.as(void 0);
}
getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
return TPromise.as(void 0);
}
Expand Down