mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
first cut of option-less open, #13807
This commit is contained in:
@@ -52,6 +52,7 @@ import * as languageConfiguration from 'vs/editor/common/modes/languageConfigura
|
||||
import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
|
||||
import { ExtHostThreadService } from "vs/workbench/services/thread/node/extHostThreadService";
|
||||
import { ProxyIdentifier } from "vs/workbench/services/thread/common/threadService";
|
||||
import { ExtHostDialogs } from "vs/workbench/api/node/extHostDialogs";
|
||||
|
||||
export interface IExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof vscode;
|
||||
@@ -105,6 +106,7 @@ export function createApiFactory(
|
||||
|
||||
// Other instances
|
||||
const extHostMessageService = new ExtHostMessageService(threadService);
|
||||
const extHostDialogs = new ExtHostDialogs(threadService);
|
||||
const extHostStatusBar = new ExtHostStatusBar(threadService);
|
||||
const extHostProgress = new ExtHostProgress(threadService.get(MainContext.MainThreadProgress));
|
||||
const extHostOutputService = new ExtHostOutputService(threadService);
|
||||
@@ -368,6 +370,9 @@ export function createApiFactory(
|
||||
sampleFunction: proposedApiFunction(extension, () => {
|
||||
return extHostMessageService.showMessage(extension.id, Severity.Info, 'Hello Proposed Api!', {}, []);
|
||||
}),
|
||||
showOpenDialog: proposedApiFunction(extension, () => {
|
||||
return extHostDialogs.showOpenDialog();
|
||||
})
|
||||
};
|
||||
|
||||
// namespace: workspace
|
||||
|
||||
@@ -113,6 +113,10 @@ export interface MainThreadDiagnosticsShape extends IDisposable {
|
||||
$clear(owner: string): TPromise<any>;
|
||||
}
|
||||
|
||||
export interface MainThreadDiaglogsShape extends IDisposable {
|
||||
$showOpenDialog(): TPromise<string[]>;
|
||||
}
|
||||
|
||||
export interface MainThreadDocumentContentProvidersShape extends IDisposable {
|
||||
$registerTextContentProvider(handle: number, scheme: string): void;
|
||||
$unregisterTextContentProvider(handle: number): void;
|
||||
@@ -532,6 +536,7 @@ export const MainContext = {
|
||||
MainThreadConfiguration: createMainId<MainThreadConfigurationShape>('MainThreadConfiguration'),
|
||||
MainThreadDebugService: createMainId<MainThreadDebugServiceShape>('MainThreadDebugService'),
|
||||
MainThreadDiagnostics: createMainId<MainThreadDiagnosticsShape>('MainThreadDiagnostics'),
|
||||
MainThreadDialogs: createMainId<MainThreadDiaglogsShape>('MainThreadDiaglogs'),
|
||||
MainThreadDocuments: createMainId<MainThreadDocumentsShape>('MainThreadDocuments'),
|
||||
MainThreadDocumentContentProviders: createMainId<MainThreadDocumentContentProvidersShape>('MainThreadDocumentContentProviders'),
|
||||
MainThreadEditors: createMainId<MainThreadEditorsShape>('MainThreadEditors'),
|
||||
|
||||
26
src/vs/workbench/api/node/extHostDialogs.ts
Normal file
26
src/vs/workbench/api/node/extHostDialogs.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { MainContext, MainThreadDiaglogsShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import URI from "vs/base/common/uri";
|
||||
|
||||
export class ExtHostDialogs {
|
||||
|
||||
private readonly _proxy: MainThreadDiaglogsShape;
|
||||
|
||||
constructor(mainContext: IMainContext) {
|
||||
this._proxy = mainContext.get(MainContext.MainThreadDialogs);
|
||||
}
|
||||
|
||||
showOpenDialog(): Thenable<URI[]> {
|
||||
return this._proxy.$showOpenDialog().then(filepaths => {
|
||||
if (!filepaths) {
|
||||
return undefined;
|
||||
}
|
||||
return filepaths.map(URI.file);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user