提交 890d482d 编写于 作者: M Martin Aeschlimann

revive path urls

上级 6a128060
......@@ -309,11 +309,28 @@ export interface IPathsToWaitFor {
waitMarkerFilePath: string;
}
export interface IPathData {
// the file path to open within a Code instance
fileUri?: UriComponents;
// the line number in the file path to open
lineNumber?: number;
// the column number in the file path to open
columnNumber?: number;
}
export interface IPathsToWaitForData {
paths: IPathData[];
waitMarkerFilePath: string;
}
export interface IOpenFileRequest {
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
filesToWait?: IPathsToWaitFor;
filesToOpen?: IPathData[];
filesToCreate?: IPathData[];
filesToDiff?: IPathData[];
filesToWait?: IPathsToWaitForData;
termProgram?: string;
}
......@@ -321,7 +338,7 @@ export interface IAddFoldersRequest {
foldersToAdd: UriComponents[];
}
export interface IWindowConfiguration extends ParsedArgs, IOpenFileRequest {
export interface IWindowConfiguration extends ParsedArgs {
machineId: string;
windowId: number;
logLevel: LogLevel;
......@@ -351,6 +368,12 @@ export interface IWindowConfiguration extends ParsedArgs, IOpenFileRequest {
perfStartTime?: number;
perfAppReady?: number;
perfWindowLoadTime?: number;
filesToOpen?: IPath[];
filesToCreate?: IPath[];
filesToDiff?: IPath[];
filesToWait?: IPathsToWaitFor;
termProgram?: string;
}
export interface IRunActionInWindowRequest {
......
......@@ -278,6 +278,7 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('getRecentlyOpened', windowId)
.then(recentlyOpened => {
recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? workspace : URI.revive(workspace));
recentlyOpened.files = recentlyOpened.files.map(URI.revive);
return recentlyOpened;
});
}
......
......@@ -15,7 +15,7 @@ import * as errors from 'vs/base/common/errors';
import * as comparer from 'vs/base/common/comparers';
import * as platform from 'vs/base/common/platform';
import * as paths from 'vs/base/common/paths';
import uri from 'vs/base/common/uri';
import uri, { UriComponents } from 'vs/base/common/uri';
import * as strings from 'vs/base/common/strings';
import { IWorkspaceContextService, Workspace, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService';
......@@ -55,6 +55,8 @@ gracefulFs.gracefulify(fs); // enable gracefulFs
export function startup(configuration: IWindowConfiguration): TPromise<void> {
revive(configuration);
// Ensure others can listen to zoom level changes
browser.setZoomFactor(webFrame.getZoomFactor());
......@@ -75,6 +77,33 @@ export function startup(configuration: IWindowConfiguration): TPromise<void> {
return openWorkbench(configuration);
}
function revive(workbench: IWindowConfiguration) {
if (workbench.folderUri) {
workbench.folderUri = uri.revive(workbench.folderUri);
}
function reviveFileUri(path: { fileUri?: UriComponents }) {
if (path.fileUri) {
path.fileUri = uri.revive(path.fileUri);
}
}
const filesToOpen = workbench.filesToOpen;
if (Array.isArray(filesToOpen)) {
filesToOpen.forEach(reviveFileUri);
}
const filesToCreate = workbench.filesToCreate;
if (Array.isArray(filesToCreate)) {
filesToCreate.forEach(reviveFileUri);
}
const filesToDiff = workbench.filesToDiff;
if (Array.isArray(filesToDiff)) {
filesToDiff.forEach(reviveFileUri);
}
const filesToWait = workbench.filesToWait;
if (filesToWait && Array.isArray(filesToWait.paths)) {
filesToWait.paths.forEach(reviveFileUri);
}
}
function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
const mainProcessClient = new ElectronIPCClient(`window:${configuration.windowId}`);
const mainServices = createMainProcessServices(mainProcessClient, configuration);
......@@ -116,8 +145,7 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
}
function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService): TPromise<WorkspaceService> {
const folderUri = configuration.folderUri ? uri.revive(configuration.folderUri) : null;
return validateFolderUri(folderUri, configuration.verbose).then(validatedFolderUri => {
return validateFolderUri(configuration.folderUri, configuration.verbose).then(validatedFolderUri => {
const workspaceService = new WorkspaceService(environmentService);
......
......@@ -18,7 +18,7 @@ import { toResource, IUntitledResourceInput } from 'vs/workbench/common/editor';
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWindowsService, IWindowService, IWindowSettings, IPath, IOpenFileRequest, IWindowsConfiguration, IAddFoldersRequest, IRunActionInWindowRequest } from 'vs/platform/windows/common/windows';
import { IWindowsService, IWindowService, IWindowSettings, IOpenFileRequest, IWindowsConfiguration, IAddFoldersRequest, IRunActionInWindowRequest, IPathData } from 'vs/platform/windows/common/windows';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IWorkbenchThemeService, VS_HC_THEME, VS_DARK_THEME } from 'vs/workbench/services/themes/common/workbenchThemeService';
......@@ -401,7 +401,7 @@ export class ElectronWindow extends Themable {
// In wait mode, listen to changes to the editors and wait until the files
// are closed that the user wants to wait for. When this happens we delete
// the wait marker file to signal to the outside that editing is done.
const resourcesToWaitFor = request.filesToWait.paths.map(p => p.fileUri);
const resourcesToWaitFor = request.filesToWait.paths.map(p => URI.revive(p.fileUri));
const waitMarkerFile = URI.file(request.filesToWait.waitMarkerFilePath);
const unbind = this.editorService.onDidCloseEditor(() => {
if (resourcesToWaitFor.every(resource => !this.editorService.isOpen({ resource }))) {
......@@ -430,9 +430,9 @@ export class ElectronWindow extends Themable {
});
}
private toInputs(paths: IPath[], isNew: boolean): IResourceEditor[] {
private toInputs(paths: IPathData[], isNew: boolean): IResourceEditor[] {
return paths.map(p => {
const resource = p.fileUri;
const resource = URI.revive(p.fileUri);
let input: IResourceInput | IUntitledResourceInput;
if (isNew) {
input = { filePath: resource.fsPath, options: { pinned: true } } as IUntitledResourceInput;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册