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

ipc: remove vscode:windowOpen, _workbench.ipc

#10587
上级 e9b674a5
......@@ -219,14 +219,6 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService
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) => {
this.logService.log('IPC#vscode-workbenchLoaded');
......
......@@ -19,6 +19,9 @@ export interface IWindowsService {
openFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void>;
reloadWindow(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');
......
......@@ -15,6 +15,7 @@ export interface IWindowsChannel extends IChannel {
call(command: 'openFolderPicker', args: [number, boolean]): TPromise<void>;
call(command: 'reloadWindow', 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>;
}
......@@ -29,6 +30,7 @@ export class WindowsChannel implements IWindowsChannel {
case 'openFolderPicker': return this.service.openFolderPicker(arg[0], arg[1]);
case 'reloadWindow': return this.service.reloadWindow(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 {
toggleDevTools(windowId: number): TPromise<void> {
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 @@
import { TPromise } from 'vs/base/common/winjs.base';
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
import { IWindowsMainService } from 'vs/code/electron-main/windows';
......@@ -16,7 +17,8 @@ export class WindowsService implements IWindowsService {
_serviceBrand: any;
constructor(
@IWindowsMainService private windowsMainService: IWindowsMainService
@IWindowsMainService private windowsMainService: IWindowsMainService,
@IEnvironmentService private environmentService: IEnvironmentService
) { }
openFileFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void> {
......@@ -53,4 +55,13 @@ export class WindowsService implements IWindowsService {
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 {
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.',
args: [
......
......@@ -10,7 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import timer = require('vs/base/common/timer');
import { Action } from 'vs/base/common/actions';
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 { EditorInput } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
......@@ -445,6 +445,7 @@ export class OpenRecentAction extends Action {
constructor(
id: string,
label: string,
@IWindowsService private windowsService: IWindowsService,
@IWindowIPCService private windowService: IWindowIPCService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
......@@ -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;
ipc.send('vscode:windowOpen', [path], newWindow);
}
this.windowsService.windowOpen([path], newWindow);
};
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));
......@@ -587,14 +587,6 @@ Steps to Reproduce:
// --- 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]) {
const editorService = accessor.get(IWorkbenchEditorService);
let [left, right, label] = args;
......
......@@ -16,6 +16,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { asFileEditorInput } from 'vs/workbench/common/editor';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { ipcRenderer as ipc, remote } from 'electron';
......@@ -30,7 +31,8 @@ export class ElectronWindow {
shellContainer: HTMLElement,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IPartService private partService: IPartService
@IPartService private partService: IPartService,
@IWindowsService private windowsService: IWindowsService
) {
this.win = win;
this.windowId = win.id;
......@@ -80,7 +82,7 @@ export class ElectronWindow {
DOM.EventHelper.stop(e, true);
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();
})
......
......@@ -18,9 +18,8 @@ import { asFileEditorInput } from 'vs/workbench/common/editor';
import { IMessageService } from 'vs/platform/message/common/message';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { ipcRenderer as ipc, clipboard } from 'electron';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { clipboard } from 'electron';
export class RevealInOSAction extends Action {
private resource: uri;
......@@ -187,6 +186,7 @@ export class ShowOpenedFileInNewWindow extends Action {
constructor(
id: string,
label: string,
@IWindowsService private windowsService: IWindowsService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IMessageService private messageService: IMessageService
) {
......@@ -196,7 +196,7 @@ export class ShowOpenedFileInNewWindow extends Action {
public run(): TPromise<any> {
const fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
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 {
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
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
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 {
......@@ -85,4 +85,9 @@ actionsRegistry.registerActionBarContributor(Scope.VIEWER, FileViewerActionContr
CommandsRegistry.registerCommand('_files.openFolderPicker', (accessor: ServicesAccessor, forceNewWindow: boolean) => {
const windowService = accessor.get(IWindowService);
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'
import * as JSONContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ipcRenderer as ipc } from 'electron';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import fs = require('fs');
class OpenSnippetsAction extends actions.Action {
......@@ -33,13 +32,14 @@ class OpenSnippetsAction extends actions.Action {
label: string,
@IEnvironmentService private environmentService: IEnvironmentService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IModeService private modeService: IModeService
@IModeService private modeService: IModeService,
@IWindowsService private windowsService: IWindowsService
) {
super(id, label);
}
private openFile(filePath: string): void {
ipc.send('vscode:windowOpen', [filePath]); // handled from browser process
private openFile(filePath: string): winjs.TPromise<void> {
return this.windowsService.windowOpen([filePath]);
}
public run(): winjs.Promise {
......@@ -60,8 +60,7 @@ class OpenSnippetsAction extends actions.Action {
var snippetPath = paths.join(this.environmentService.appSettingsHome, 'snippets', language.id + '.json');
return fileExists(snippetPath).then((success) => {
if (success) {
this.openFile(snippetPath);
return winjs.TPromise.as(null);
return this.openFile(snippetPath);
}
var defaultContent = [
'{',
......@@ -82,7 +81,7 @@ class OpenSnippetsAction extends actions.Action {
'}'
].join('\n');
return createFile(snippetPath, defaultContent).then(() => {
this.openFile(snippetPath);
return this.openFile(snippetPath);
}, (err) => {
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.
先完成此消息的编辑!
想要评论请 注册