提交 6b370393 编写于 作者: B Benjamin Pasero

Provide API to open a new folder (fixes #58)

* Provide API to open a new folder (fixes #58)

* extract more generic command

* use underscore to prevent command from showing in keybindings list
上级 6486b193
......@@ -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
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册