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

no more passing around of recent files/folders

上级 6c6a595a
......@@ -96,9 +96,6 @@ export interface IWindowConfiguration extends ICommandLineArguments {
workspacePath?: string;
recentFiles: string[];
recentFolders: string[];
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
......
......@@ -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) => {
this.logService.log('IPC#vscode:focusWindow');
......@@ -735,10 +746,6 @@ export class WindowsManager implements IWindowsService {
configuration.filesToDiff = filesToDiff;
configuration.extensionsToInstall = extensionsToInstall;
const recents = this.getRecentlyOpenedPaths(workspacePath, filesToOpen);
configuration.recentFiles = recents.files;
configuration.recentFolders = recents.folders;
return configuration;
}
......
......@@ -46,12 +46,6 @@ export interface IOptions {
*/
editor?: IEditorOptions;
/**
* Recent files and folders
*/
recentFiles?: string[];
recentFolders?: string[];
/**
* The global application settings if any.
*/
......
......@@ -8,20 +8,16 @@
import URI from 'vs/base/common/uri';
import {TPromise} from 'vs/base/common/winjs.base';
import timer = require('vs/base/common/timer');
import paths = require('vs/base/common/paths');
import {Action} from 'vs/base/common/actions';
import {IWindowService} from 'vs/workbench/services/window/electron-browser/windowService';
import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService';
import {EditorInput} from 'vs/workbench/common/editor';
import {isMacintosh} from 'vs/base/common/platform';
import {DiffEditorInput} from 'vs/workbench/common/editor/diffEditorInput';
import nls = require('vs/nls');
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {IWindowConfiguration} from 'vs/workbench/electron-browser/window';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
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 {CommandsRegistry} from 'vs/platform/commands/common/commands';
import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
......@@ -375,49 +371,15 @@ export class OpenRecentAction extends Action {
constructor(
id: string,
label: string,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IQuickOpenService private quickOpenService: IQuickOpenService
@IWindowService private windowService: IWindowService
) {
super(id, label);
}
public run(): TPromise<boolean> {
const recentFolders = this.contextService.getOptions().recentFolders;
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)
};
});
ipc.send('vscode:openRecent', this.windowService.getWindowId());
const hasWorkspace = !!this.contextService.getWorkspace();
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);
return TPromise.as(true);
}
}
......
......@@ -6,10 +6,12 @@
'use strict';
import nls = require('vs/nls');
import paths = require('vs/base/common/paths');
import {TPromise} from 'vs/base/common/winjs.base';
import errors = require('vs/base/common/errors');
import arrays = require('vs/base/common/arrays');
import Severity from 'vs/base/common/severity';
import {isMacintosh} from 'vs/base/common/platform';
import {Separator} from 'vs/base/browser/ui/actionbar/actionbar';
import {IAction, Action} from 'vs/base/common/actions';
import {IPartService} from 'vs/workbench/services/part/common/partService';
......@@ -25,6 +27,8 @@ import {IWindowConfiguration} from 'vs/workbench/electron-browser/window';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {ElectronWindow} from 'vs/workbench/electron-browser/window';
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';
......@@ -53,6 +57,7 @@ export class ElectronIntegration {
@ICommandService private commandService: ICommandService,
@IKeybindingService private keybindingService: IKeybindingService,
@IMessageService private messageService: IMessageService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IContextMenuService private contextMenuService: IContextMenuService
) {
}
......@@ -118,6 +123,11 @@ export class ElectronIntegration {
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
browser.setZoomLevel(webFrame.getZoomLevel());
......@@ -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; }[]> {
return this.partService.joinCreation().then(() => {
return arrays.coalesce(actionIds.map((id) => {
......
......@@ -54,9 +54,6 @@ export interface IWindowConfiguration extends IEnvironment {
workspacePath?: string;
recentFiles?: string[];
recentFolders?: string[];
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
......@@ -75,8 +72,6 @@ export function startup(configuration: IWindowConfiguration, globalSettings: IGl
filesToOpen,
filesToCreate,
filesToDiff,
recentFiles: configuration.recentFiles,
recentFolders: configuration.recentFolders,
extensionsToInstall: configuration.extensionsToInstall,
globalSettings
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册