提交 ae63b195 编写于 作者: J Joao Moreno

ipc: remove vscode:windowOpen, _workbench.ipc

#10587
上级 e9b674a5
...@@ -219,14 +219,6 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService ...@@ -219,14 +219,6 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService
crashReporter.start(config); crashReporter.start(config);
}); });
ipc.on('vscode:windowOpen', (event, paths: string[], forceNewWindow?: boolean) => {
this.logService.log('IPC#vscode-windowOpen: ', paths);
if (paths && paths.length) {
this.open({ cli: this.environmentService.args, pathsToOpen: paths, forceNewWindow: forceNewWindow });
}
});
ipc.on('vscode:workbenchLoaded', (event, windowId: number) => { ipc.on('vscode:workbenchLoaded', (event, windowId: number) => {
this.logService.log('IPC#vscode-workbenchLoaded'); this.logService.log('IPC#vscode-workbenchLoaded');
......
...@@ -19,6 +19,9 @@ export interface IWindowsService { ...@@ -19,6 +19,9 @@ export interface IWindowsService {
openFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void>; openFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void>;
reloadWindow(windowId: number): TPromise<void>; reloadWindow(windowId: number): TPromise<void>;
toggleDevTools(windowId: number): TPromise<void>; toggleDevTools(windowId: number): TPromise<void>;
// TODO@joao: rename
windowOpen(paths: string[], forceNewWindow?: boolean): TPromise<void>;
} }
export const IWindowService = createDecorator<IWindowService>('windowService'); export const IWindowService = createDecorator<IWindowService>('windowService');
......
...@@ -15,6 +15,7 @@ export interface IWindowsChannel extends IChannel { ...@@ -15,6 +15,7 @@ export interface IWindowsChannel extends IChannel {
call(command: 'openFolderPicker', args: [number, boolean]): TPromise<void>; call(command: 'openFolderPicker', args: [number, boolean]): TPromise<void>;
call(command: 'reloadWindow', arg: number): TPromise<void>; call(command: 'reloadWindow', arg: number): TPromise<void>;
call(command: 'toggleDevTools', arg: number): TPromise<void>; call(command: 'toggleDevTools', arg: number): TPromise<void>;
call(command: 'windowOpen', arg: [string[], boolean]): TPromise<void>;
call(command: string, arg?: any): TPromise<any>; call(command: string, arg?: any): TPromise<any>;
} }
...@@ -29,6 +30,7 @@ export class WindowsChannel implements IWindowsChannel { ...@@ -29,6 +30,7 @@ export class WindowsChannel implements IWindowsChannel {
case 'openFolderPicker': return this.service.openFolderPicker(arg[0], arg[1]); case 'openFolderPicker': return this.service.openFolderPicker(arg[0], arg[1]);
case 'reloadWindow': return this.service.reloadWindow(arg); case 'reloadWindow': return this.service.reloadWindow(arg);
case 'toggleDevTools': return this.service.toggleDevTools(arg); case 'toggleDevTools': return this.service.toggleDevTools(arg);
case 'windowOpen': return this.service.windowOpen(arg[0], arg[1]);
} }
} }
} }
...@@ -58,4 +60,8 @@ export class WindowsChannelClient implements IWindowsService { ...@@ -58,4 +60,8 @@ export class WindowsChannelClient implements IWindowsService {
toggleDevTools(windowId: number): TPromise<void> { toggleDevTools(windowId: number): TPromise<void> {
return this.channel.call('toggleDevTools', windowId); return this.channel.call('toggleDevTools', windowId);
} }
windowOpen(paths: string[], forceNewWindow?: boolean): TPromise<void> {
return this.channel.call('windowOpen', [paths, forceNewWindow]);
}
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { IWindowsService } from 'vs/platform/windows/common/windows'; import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
// TODO@Joao: remove this dependency, move all implementation to this class // TODO@Joao: remove this dependency, move all implementation to this class
import { IWindowsMainService } from 'vs/code/electron-main/windows'; import { IWindowsMainService } from 'vs/code/electron-main/windows';
...@@ -16,7 +17,8 @@ export class WindowsService implements IWindowsService { ...@@ -16,7 +17,8 @@ export class WindowsService implements IWindowsService {
_serviceBrand: any; _serviceBrand: any;
constructor( constructor(
@IWindowsMainService private windowsMainService: IWindowsMainService @IWindowsMainService private windowsMainService: IWindowsMainService,
@IEnvironmentService private environmentService: IEnvironmentService
) { } ) { }
openFileFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void> { openFileFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void> {
...@@ -53,4 +55,13 @@ export class WindowsService implements IWindowsService { ...@@ -53,4 +55,13 @@ export class WindowsService implements IWindowsService {
return TPromise.as(null); return TPromise.as(null);
} }
windowOpen(paths: string[], forceNewWindow?: boolean): TPromise<void> {
if (!paths || !paths.length) {
return TPromise.as(null);
}
this.windowsMainService.open({ cli: this.environmentService.args, pathsToOpen: paths, forceNewWindow: forceNewWindow });
return TPromise.as(null);
}
} }
\ No newline at end of file
...@@ -188,7 +188,7 @@ export class ExtHostApiCommands { ...@@ -188,7 +188,7 @@ export class ExtHostApiCommands {
return this._commands.executeCommand('_files.openFolderPicker', forceNewWindow); return this._commands.executeCommand('_files.openFolderPicker', forceNewWindow);
} }
return this._commands.executeCommand('_workbench.ipc', 'vscode:windowOpen', [[uri.fsPath], forceNewWindow]); return this._commands.executeCommand('_files.windowOpen', [uri.fsPath], forceNewWindow);
}, { }, {
description: 'Open a folder in the current window or new window depending on the newWindow argument. Note that opening in the same window will shutdown the current extension host process and start a new one on the given folder unless the newWindow parameter is set to true.', description: 'Open a folder in the current window or new window depending on the newWindow argument. Note that opening in the same window will shutdown the current extension host process and start a new one on the given folder unless the newWindow parameter is set to true.',
args: [ args: [
......
...@@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; ...@@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import timer = require('vs/base/common/timer'); import timer = require('vs/base/common/timer');
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService'; import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IWindowService } from 'vs/platform/windows/common/windows'; import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
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 { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
...@@ -445,6 +445,7 @@ export class OpenRecentAction extends Action { ...@@ -445,6 +445,7 @@ export class OpenRecentAction extends Action {
constructor( constructor(
id: string, id: string,
label: string, label: string,
@IWindowsService private windowsService: IWindowsService,
@IWindowIPCService private windowService: IWindowIPCService, @IWindowIPCService private windowService: IWindowIPCService,
@IQuickOpenService private quickOpenService: IQuickOpenService, @IQuickOpenService private quickOpenService: IQuickOpenService,
@IWorkspaceContextService private contextService: IWorkspaceContextService @IWorkspaceContextService private contextService: IWorkspaceContextService
...@@ -476,11 +477,10 @@ export class OpenRecentAction extends Action { ...@@ -476,11 +477,10 @@ export class OpenRecentAction extends Action {
}; };
} }
function runPick(path: string, context): void { const runPick = (path: string, context) => {
const newWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; const newWindow = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0;
this.windowsService.windowOpen([path], newWindow);
ipc.send('vscode:windowOpen', [path], newWindow); };
}
const folderPicks: IFilePickOpenEntry[] = recentFolders.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('folders', "folders") } : void 0, true)); const folderPicks: IFilePickOpenEntry[] = recentFolders.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('folders', "folders") } : void 0, true));
const filePicks: IFilePickOpenEntry[] = recentFiles.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('files', "files"), border: true } : void 0, false)); const filePicks: IFilePickOpenEntry[] = recentFiles.map((p, index) => toPick(p, index === 0 ? { label: nls.localize('files', "files"), border: true } : void 0, false));
...@@ -587,14 +587,6 @@ Steps to Reproduce: ...@@ -587,14 +587,6 @@ Steps to Reproduce:
// --- commands // --- commands
CommandsRegistry.registerCommand('_workbench.ipc', function (accessor: ServicesAccessor, ipcMessage: string, ipcArgs: any[]) {
if (ipcMessage && Array.isArray(ipcArgs)) {
ipc.send(ipcMessage, ...ipcArgs);
} else {
ipc.send(ipcMessage);
}
});
CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string]) { CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string]) {
const editorService = accessor.get(IWorkbenchEditorService); const editorService = accessor.get(IWorkbenchEditorService);
let [left, right, label] = args; let [left, right, label] = args;
......
...@@ -16,6 +16,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService'; ...@@ -16,6 +16,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { asFileEditorInput } from 'vs/workbench/common/editor'; import { asFileEditorInput } from 'vs/workbench/common/editor';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { ipcRenderer as ipc, remote } from 'electron'; import { ipcRenderer as ipc, remote } from 'electron';
...@@ -30,7 +31,8 @@ export class ElectronWindow { ...@@ -30,7 +31,8 @@ export class ElectronWindow {
shellContainer: HTMLElement, shellContainer: HTMLElement,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService, @IEditorGroupService private editorGroupService: IEditorGroupService,
@IPartService private partService: IPartService @IPartService private partService: IPartService,
@IWindowsService private windowsService: IWindowsService
) { ) {
this.win = win; this.win = win;
this.windowId = win.id; this.windowId = win.id;
...@@ -80,7 +82,7 @@ export class ElectronWindow { ...@@ -80,7 +82,7 @@ export class ElectronWindow {
DOM.EventHelper.stop(e, true); DOM.EventHelper.stop(e, true);
this.focus(); // make sure this window has focus so that the open call reaches the right window! this.focus(); // make sure this window has focus so that the open call reaches the right window!
ipc.send('vscode:windowOpen', draggedExternalResources.map(r => r.fsPath)); // handled from browser process this.windowsService.windowOpen(draggedExternalResources.map(r => r.fsPath));
cleanUp(); cleanUp();
}) })
......
...@@ -18,9 +18,8 @@ import { asFileEditorInput } from 'vs/workbench/common/editor'; ...@@ -18,9 +18,8 @@ import { asFileEditorInput } from 'vs/workbench/common/editor';
import { IMessageService } from 'vs/platform/message/common/message'; import { IMessageService } from 'vs/platform/message/common/message';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService'; import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IWindowService } from 'vs/platform/windows/common/windows'; import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { clipboard } from 'electron';
import { ipcRenderer as ipc, clipboard } from 'electron';
export class RevealInOSAction extends Action { export class RevealInOSAction extends Action {
private resource: uri; private resource: uri;
...@@ -187,6 +186,7 @@ export class ShowOpenedFileInNewWindow extends Action { ...@@ -187,6 +186,7 @@ export class ShowOpenedFileInNewWindow extends Action {
constructor( constructor(
id: string, id: string,
label: string, label: string,
@IWindowsService private windowsService: IWindowsService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IMessageService private messageService: IMessageService @IMessageService private messageService: IMessageService
) { ) {
...@@ -196,7 +196,7 @@ export class ShowOpenedFileInNewWindow extends Action { ...@@ -196,7 +196,7 @@ export class ShowOpenedFileInNewWindow extends Action {
public run(): TPromise<any> { public run(): TPromise<any> {
const fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true); const fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
if (fileInput) { if (fileInput) {
ipc.send('vscode:windowOpen', [fileInput.getResource().fsPath], true /* force new window */); // handled from browser process this.windowsService.windowOpen([fileInput.getResource().fsPath], true);
} else { } else {
this.messageService.show(severity.Info, nls.localize('openFileToShow', "Open a file first to open in new window")); this.messageService.show(severity.Info, nls.localize('openFileToShow', "Open a file first to open in new window"));
} }
......
...@@ -21,7 +21,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti ...@@ -21,7 +21,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
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';
import { IWindowService } from 'vs/platform/windows/common/windows'; import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
class FileViewerActionContributor extends ActionBarContributor { class FileViewerActionContributor extends ActionBarContributor {
...@@ -86,3 +86,8 @@ CommandsRegistry.registerCommand('_files.openFolderPicker', (accessor: ServicesA ...@@ -86,3 +86,8 @@ CommandsRegistry.registerCommand('_files.openFolderPicker', (accessor: ServicesA
const windowService = accessor.get(IWindowService); const windowService = accessor.get(IWindowService);
windowService.openFolderPicker(forceNewWindow); windowService.openFolderPicker(forceNewWindow);
}); });
CommandsRegistry.registerCommand('_files.windowOpen', (accessor: ServicesAccessor, paths: string[], forceNewWindow: boolean) => {
const windowsService = accessor.get(IWindowsService);
windowsService.windowOpen(paths, forceNewWindow);
});
\ No newline at end of file
...@@ -19,8 +19,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' ...@@ -19,8 +19,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import * as JSONContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry'; import * as JSONContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { IModeService } from 'vs/editor/common/services/modeService'; import { IModeService } from 'vs/editor/common/services/modeService';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { ipcRenderer as ipc } from 'electron';
import fs = require('fs'); import fs = require('fs');
class OpenSnippetsAction extends actions.Action { class OpenSnippetsAction extends actions.Action {
...@@ -33,13 +32,14 @@ class OpenSnippetsAction extends actions.Action { ...@@ -33,13 +32,14 @@ class OpenSnippetsAction extends actions.Action {
label: string, label: string,
@IEnvironmentService private environmentService: IEnvironmentService, @IEnvironmentService private environmentService: IEnvironmentService,
@IQuickOpenService private quickOpenService: IQuickOpenService, @IQuickOpenService private quickOpenService: IQuickOpenService,
@IModeService private modeService: IModeService @IModeService private modeService: IModeService,
@IWindowsService private windowsService: IWindowsService
) { ) {
super(id, label); super(id, label);
} }
private openFile(filePath: string): void { private openFile(filePath: string): winjs.TPromise<void> {
ipc.send('vscode:windowOpen', [filePath]); // handled from browser process return this.windowsService.windowOpen([filePath]);
} }
public run(): winjs.Promise { public run(): winjs.Promise {
...@@ -60,8 +60,7 @@ class OpenSnippetsAction extends actions.Action { ...@@ -60,8 +60,7 @@ class OpenSnippetsAction extends actions.Action {
var snippetPath = paths.join(this.environmentService.appSettingsHome, 'snippets', language.id + '.json'); var snippetPath = paths.join(this.environmentService.appSettingsHome, 'snippets', language.id + '.json');
return fileExists(snippetPath).then((success) => { return fileExists(snippetPath).then((success) => {
if (success) { if (success) {
this.openFile(snippetPath); return this.openFile(snippetPath);
return winjs.TPromise.as(null);
} }
var defaultContent = [ var defaultContent = [
'{', '{',
...@@ -82,7 +81,7 @@ class OpenSnippetsAction extends actions.Action { ...@@ -82,7 +81,7 @@ class OpenSnippetsAction extends actions.Action {
'}' '}'
].join('\n'); ].join('\n');
return createFile(snippetPath, defaultContent).then(() => { return createFile(snippetPath, defaultContent).then(() => {
this.openFile(snippetPath); return this.openFile(snippetPath);
}, (err) => { }, (err) => {
errors.onUnexpectedError(nls.localize('openSnippet.errorOnCreate', 'Unable to create {0}', snippetPath)); errors.onUnexpectedError(nls.localize('openSnippet.errorOnCreate', 'Unable to create {0}', snippetPath));
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册