diff --git a/src/vs/workbench/api/node/extHostApiCommands.ts b/src/vs/workbench/api/node/extHostApiCommands.ts index c664de175e7031b76e3f157a022c5f7718030472..5e2daec330ca337fd99939a02fb1fdb190a184e9 100644 --- a/src/vs/workbench/api/node/extHostApiCommands.ts +++ b/src/vs/workbench/api/node/extHostApiCommands.ts @@ -162,6 +162,13 @@ class ExtHostApiCommands { { name: 'column', description: '(optional) Column in which to preview.' }, ] }); + + this._register('vscode.openFolder', (uri: URI) => this._commands.executeCommand('_workbench.ipc', 'vscode:windowOpen', [[uri.fsPath]]), { + description: 'Open a folder in the current window. Note that this will shutdown the current extension host process and start a new one on the given folder.', + args: [ + { name: 'uri', description: 'Uri of the folder to open.', constraint: URI } + ] + }); } // --- command impl diff --git a/src/vs/workbench/electron-browser/actions.ts b/src/vs/workbench/electron-browser/actions.ts index b4a77572480444fe7fd1a36d869f20dd523a2034..8eccd0b0cc1714b12f235a8f86be692d6043e6a4 100644 --- a/src/vs/workbench/electron-browser/actions.ts +++ b/src/vs/workbench/electron-browser/actions.ts @@ -17,9 +17,13 @@ import {IWindowConfiguration} from 'vs/workbench/electron-browser/window'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpenService'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; +import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; +import {ServicesAccessor} from 'vs/platform/instantiation/common/instantiation'; import {ipcRenderer as ipc, webFrame, remote} from 'electron'; +// --- actions + export class CloseEditorAction extends Action { public static ID = 'workbench.action.closeActiveEditor'; @@ -458,4 +462,23 @@ export class CloseMessagesAction extends Action { return TPromise.as(true); } -} \ No newline at end of file +} + +// --- commands + +KeybindingsRegistry.registerCommandDesc({ + id: '_workbench.ipc', + weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0), + handler(accessor: ServicesAccessor, args: [string, any[]]) { + const ipcMessage = args[0]; + const ipcArgs = args[1]; + + if (ipcMessage && Array.isArray(ipcArgs)) { + ipc.send(ipcMessage, ...ipcArgs); + } else { + ipc.send(ipcMessage); + } + }, + context: undefined, + primary: undefined +}); \ No newline at end of file