diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index f659d20660c..f95e97c3ced 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -16,6 +16,17 @@ declare module 'vscode' { + //#region Joh - vscode.open + + export namespace window { + /** + * + */ + export function open(uri: Uri): void; + } + + //#endregion + //#region Joh - selection range provider export class SelectionRangeKind { diff --git a/src/vs/workbench/api/electron-browser/mainThreadWindow.ts b/src/vs/workbench/api/electron-browser/mainThreadWindow.ts index 4c20602bd21..752cba581d5 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWindow.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWindow.ts @@ -8,6 +8,8 @@ import { MainThreadWindowShape, ExtHostWindowShape, ExtHostContext, MainContext, import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; import { Event } from 'vs/base/common/event'; +import { UriComponents, URI } from 'vs/base/common/uri'; +import { ICommandService } from 'vs/platform/commands/common/commands'; @extHostNamedCustomer(MainContext.MainThreadWindow) export class MainThreadWindow implements MainThreadWindowShape { @@ -17,7 +19,8 @@ export class MainThreadWindow implements MainThreadWindowShape { constructor( extHostContext: IExtHostContext, - @IWindowService private readonly windowService: IWindowService + @IWindowService private readonly windowService: IWindowService, + @ICommandService private readonly commandService: ICommandService, ) { this.proxy = extHostContext.getProxy(ExtHostContext.ExtHostWindow); @@ -25,11 +28,17 @@ export class MainThreadWindow implements MainThreadWindowShape { (this.proxy.$onDidChangeWindowFocus, this.proxy, this.disposables); } + dispose(): void { + this.disposables = dispose(this.disposables); + } + $getWindowVisibility(): Promise { return this.windowService.isFocused(); } - dispose(): void { - this.disposables = dispose(this.disposables); + $openUri(uri: UriComponents): Promise { + // todo@joh turn this around and let the command work with + // the proper implementation + return this.commandService.executeCommand('_workbench.open', URI.revive(uri)); } } diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index efaabac633b..6cb7c089487 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -497,6 +497,9 @@ export function createApiFactory( createInputBox(): vscode.InputBox { return extHostQuickOpen.createInputBox(extension.identifier); }, + open: proposedApiFunction(extension, (uri: URI) => { + return extHostWindow.openUri(uri); + }) }; // namespace: workspace diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 9a26e5fa431..04635c90791 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -621,6 +621,7 @@ export interface MainThreadDebugServiceShape extends IDisposable { export interface MainThreadWindowShape extends IDisposable { $getWindowVisibility(): Promise; + $openUri(uri: UriComponents): Promise; } // -- extension host diff --git a/src/vs/workbench/api/node/extHostWindow.ts b/src/vs/workbench/api/node/extHostWindow.ts index 7eafd3bd06b..e995982451a 100644 --- a/src/vs/workbench/api/node/extHostWindow.ts +++ b/src/vs/workbench/api/node/extHostWindow.ts @@ -6,6 +6,7 @@ import { Event, Emitter } from 'vs/base/common/event'; import { ExtHostWindowShape, MainContext, MainThreadWindowShape, IMainContext } from './extHost.protocol'; import { WindowState } from 'vscode'; +import { URI } from 'vs/base/common/uri'; export class ExtHostWindow implements ExtHostWindowShape { @@ -34,4 +35,8 @@ export class ExtHostWindow implements ExtHostWindowShape { this._state = { ...this._state, focused }; this._onDidChangeWindowState.fire(this._state); } + + openUri(uri: URI): Promise { + return this._proxy.$openUri(uri); + } }