提交 17146e8e 编写于 作者: B Benjamin Pasero

no more passing around of recent files/folders

上级 6c6a595a
...@@ -96,9 +96,6 @@ export interface IWindowConfiguration extends ICommandLineArguments { ...@@ -96,9 +96,6 @@ export interface IWindowConfiguration extends ICommandLineArguments {
workspacePath?: string; workspacePath?: string;
recentFiles: string[];
recentFolders: string[];
filesToOpen?: IPath[]; filesToOpen?: IPath[];
filesToCreate?: IPath[]; filesToCreate?: IPath[];
filesToDiff?: IPath[]; filesToDiff?: IPath[];
......
...@@ -329,6 +329,17 @@ export class WindowsManager implements IWindowsService { ...@@ -329,6 +329,17 @@ export class WindowsManager implements IWindowsService {
} }
}); });
ipc.on('vscode:openRecent', (event, windowId: number) => {
this.logService.log('IPC#vscode:openRecent');
let vscodeWindow = this.getWindowById(windowId);
if (vscodeWindow) {
const recents = this.getRecentlyOpenedPaths(vscodeWindow.config.workspacePath, vscodeWindow.config.filesToOpen);
vscodeWindow.send('vscode:openRecent', recents.files, recents.folders);
}
});
ipc.on('vscode:focusWindow', (event, windowId: number) => { ipc.on('vscode:focusWindow', (event, windowId: number) => {
this.logService.log('IPC#vscode:focusWindow'); this.logService.log('IPC#vscode:focusWindow');
...@@ -735,10 +746,6 @@ export class WindowsManager implements IWindowsService { ...@@ -735,10 +746,6 @@ export class WindowsManager implements IWindowsService {
configuration.filesToDiff = filesToDiff; configuration.filesToDiff = filesToDiff;
configuration.extensionsToInstall = extensionsToInstall; configuration.extensionsToInstall = extensionsToInstall;
const recents = this.getRecentlyOpenedPaths(workspacePath, filesToOpen);
configuration.recentFiles = recents.files;
configuration.recentFolders = recents.folders;
return configuration; return configuration;
} }
......
...@@ -46,12 +46,6 @@ export interface IOptions { ...@@ -46,12 +46,6 @@ export interface IOptions {
*/ */
editor?: IEditorOptions; editor?: IEditorOptions;
/**
* Recent files and folders
*/
recentFiles?: string[];
recentFolders?: string[];
/** /**
* The global application settings if any. * The global application settings if any.
*/ */
......
...@@ -8,20 +8,16 @@ ...@@ -8,20 +8,16 @@
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import {TPromise} from 'vs/base/common/winjs.base'; import {TPromise} from 'vs/base/common/winjs.base';
import timer = require('vs/base/common/timer'); import timer = require('vs/base/common/timer');
import paths = require('vs/base/common/paths');
import {Action} from 'vs/base/common/actions'; import {Action} from 'vs/base/common/actions';
import {IWindowService} from 'vs/workbench/services/window/electron-browser/windowService'; import {IWindowService} from 'vs/workbench/services/window/electron-browser/windowService';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {EditorInput} from 'vs/workbench/common/editor'; import {EditorInput} from 'vs/workbench/common/editor';
import {isMacintosh} from 'vs/base/common/platform';
import {DiffEditorInput} from 'vs/workbench/common/editor/diffEditorInput'; import {DiffEditorInput} from 'vs/workbench/common/editor/diffEditorInput';
import nls = require('vs/nls'); import nls = require('vs/nls');
import {IMessageService, Severity} from 'vs/platform/message/common/message'; import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {IWindowConfiguration} from 'vs/workbench/electron-browser/window'; import {IWindowConfiguration} from 'vs/workbench/electron-browser/window';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IEnvironmentService} from 'vs/platform/environment/common/environment'; import {IEnvironmentService} from 'vs/platform/environment/common/environment';
import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {KeyMod} from 'vs/base/common/keyCodes';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {CommandsRegistry} from 'vs/platform/commands/common/commands'; import {CommandsRegistry} from 'vs/platform/commands/common/commands';
import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation'; import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
...@@ -375,49 +371,15 @@ export class OpenRecentAction extends Action { ...@@ -375,49 +371,15 @@ export class OpenRecentAction extends Action {
constructor( constructor(
id: string, id: string,
label: string, label: string,
@IWorkspaceContextService private contextService: IWorkspaceContextService, @IWindowService private windowService: IWindowService
@IQuickOpenService private quickOpenService: IQuickOpenService
) { ) {
super(id, label); super(id, label);
} }
public run(): TPromise<boolean> { public run(): TPromise<boolean> {
const recentFolders = this.contextService.getOptions().recentFolders; ipc.send('vscode:openRecent', this.windowService.getWindowId());
const recentFiles = this.contextService.getOptions().recentFiles;
const folderPicks: IPickOpenEntry[] = recentFolders.map((p, index) => {
return {
label: paths.basename(p),
description: paths.dirname(p),
path: p,
separator: index === 0 ? { label: nls.localize('folders', "folders") } : void 0,
run: (context) => this.runPick(p, context)
};
});
const filePicks: IPickOpenEntry[] = recentFiles.map((p, index) => {
return {
label: paths.basename(p),
description: paths.dirname(p),
path: p,
separator: index === 0 ? { label: nls.localize('files', "files"), border: true } : void 0,
run: (context) => this.runPick(p, context)
};
});
const hasWorkspace = !!this.contextService.getWorkspace(); return TPromise.as(true);
return this.quickOpenService.pick(folderPicks.concat(...filePicks), {
autoFocus: { autoFocusFirstEntry: !hasWorkspace, autoFocusSecondEntry: hasWorkspace },
placeHolder: isMacintosh ? nls.localize('openRecentPlaceHolderMac', "Select a path (hold Cmd-key to open in new window)") : nls.localize('openRecentPlaceHolder', "Select a path to open (hold Ctrl-key to open in new window)"),
matchOnDescription: true
}).then(p => true);
}
private runPick(path, context): void {
const newWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0;
ipc.send('vscode:windowOpen', [path], newWindow);
} }
} }
......
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
'use strict'; 'use strict';
import nls = require('vs/nls'); import nls = require('vs/nls');
import paths = require('vs/base/common/paths');
import {TPromise} from 'vs/base/common/winjs.base'; import {TPromise} from 'vs/base/common/winjs.base';
import errors = require('vs/base/common/errors'); import errors = require('vs/base/common/errors');
import arrays = require('vs/base/common/arrays'); import arrays = require('vs/base/common/arrays');
import Severity from 'vs/base/common/severity'; import Severity from 'vs/base/common/severity';
import {isMacintosh} from 'vs/base/common/platform';
import {Separator} from 'vs/base/browser/ui/actionbar/actionbar'; import {Separator} from 'vs/base/browser/ui/actionbar/actionbar';
import {IAction, Action} from 'vs/base/common/actions'; import {IAction, Action} from 'vs/base/common/actions';
import {IPartService} from 'vs/workbench/services/part/common/partService'; import {IPartService} from 'vs/workbench/services/part/common/partService';
...@@ -25,6 +27,8 @@ import {IWindowConfiguration} from 'vs/workbench/electron-browser/window'; ...@@ -25,6 +27,8 @@ import {IWindowConfiguration} from 'vs/workbench/electron-browser/window';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {ElectronWindow} from 'vs/workbench/electron-browser/window'; import {ElectronWindow} from 'vs/workbench/electron-browser/window';
import * as browser from 'vs/base/browser/browser'; import * as browser from 'vs/base/browser/browser';
import {IQuickOpenService, IPickOpenEntry, ISeparator} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {KeyMod} from 'vs/base/common/keyCodes';
import {ipcRenderer as ipc, webFrame, remote} from 'electron'; import {ipcRenderer as ipc, webFrame, remote} from 'electron';
...@@ -53,6 +57,7 @@ export class ElectronIntegration { ...@@ -53,6 +57,7 @@ export class ElectronIntegration {
@ICommandService private commandService: ICommandService, @ICommandService private commandService: ICommandService,
@IKeybindingService private keybindingService: IKeybindingService, @IKeybindingService private keybindingService: IKeybindingService,
@IMessageService private messageService: IMessageService, @IMessageService private messageService: IMessageService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IContextMenuService private contextMenuService: IContextMenuService @IContextMenuService private contextMenuService: IContextMenuService
) { ) {
} }
...@@ -118,6 +123,11 @@ export class ElectronIntegration { ...@@ -118,6 +123,11 @@ export class ElectronIntegration {
this.messageService.show(Severity.Info, message); this.messageService.show(Severity.Info, message);
}); });
// Recent files / folders
ipc.on('vscode:openRecent', (event, files: string[], folders: string[]) => {
this.openRecent(files, folders);
});
// Ensure others can listen to zoom level changes // Ensure others can listen to zoom level changes
browser.setZoomLevel(webFrame.getZoomLevel()); browser.setZoomLevel(webFrame.getZoomLevel());
...@@ -169,6 +179,34 @@ export class ElectronIntegration { ...@@ -169,6 +179,34 @@ export class ElectronIntegration {
}); });
} }
private openRecent(recentFiles: string[], recentFolders: string[]): void {
function toPick(path: string, separator: ISeparator): IPickOpenEntry {
return {
label: paths.basename(path),
description: paths.dirname(path),
separator,
run: (context) => runPick(path, context)
};
}
function runPick(path: string, context): void {
const newWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0;
ipc.send('vscode:windowOpen', [path], newWindow);
}
const folderPicks: IPickOpenEntry[] = recentFolders.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('folders', "folders") } : void 0));
const filePicks: IPickOpenEntry[] = recentFiles.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('files', "files"), border: true } : void 0));
const hasWorkspace = !!this.contextService.getWorkspace();
this.quickOpenService.pick(folderPicks.concat(...filePicks), {
autoFocus: { autoFocusFirstEntry: !hasWorkspace, autoFocusSecondEntry: hasWorkspace },
placeHolder: isMacintosh ? nls.localize('openRecentPlaceHolderMac', "Select a path (hold Cmd-key to open in new window)") : nls.localize('openRecentPlaceHolder', "Select a path to open (hold Ctrl-key to open in new window)"),
matchOnDescription: true
}).done(null, errors.onUnexpectedError);
}
private resolveKeybindings(actionIds: string[]): TPromise<{ id: string; binding: number; }[]> { private resolveKeybindings(actionIds: string[]): TPromise<{ id: string; binding: number; }[]> {
return this.partService.joinCreation().then(() => { return this.partService.joinCreation().then(() => {
return arrays.coalesce(actionIds.map((id) => { return arrays.coalesce(actionIds.map((id) => {
......
...@@ -54,9 +54,6 @@ export interface IWindowConfiguration extends IEnvironment { ...@@ -54,9 +54,6 @@ export interface IWindowConfiguration extends IEnvironment {
workspacePath?: string; workspacePath?: string;
recentFiles?: string[];
recentFolders?: string[];
filesToOpen?: IPath[]; filesToOpen?: IPath[];
filesToCreate?: IPath[]; filesToCreate?: IPath[];
filesToDiff?: IPath[]; filesToDiff?: IPath[];
...@@ -75,8 +72,6 @@ export function startup(configuration: IWindowConfiguration, globalSettings: IGl ...@@ -75,8 +72,6 @@ export function startup(configuration: IWindowConfiguration, globalSettings: IGl
filesToOpen, filesToOpen,
filesToCreate, filesToCreate,
filesToDiff, filesToDiff,
recentFiles: configuration.recentFiles,
recentFolders: configuration.recentFolders,
extensionsToInstall: configuration.extensionsToInstall, extensionsToInstall: configuration.extensionsToInstall,
globalSettings globalSettings
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册