mirror of
https://github.com/Microsoft/vscode
synced 2024-06-30 23:04:56 +00:00
Alexr00/showLocalAPI (#173798)
* Propose "allowLocal" open dialog option API Part of #131138 * Update comment * allowUIResources API proposal Part of #131138 * Fix scheme ordering and update doc comment
This commit is contained in:
parent
7f48e7c7ce
commit
89c4f61de2
|
@ -8,7 +8,7 @@ import { TSESTree } from '@typescript-eslint/experimental-utils';
|
|||
|
||||
export = new class ApiInterfaceNaming implements eslint.Rule.RuleModule {
|
||||
|
||||
private static _nameRegExp = /I[A-Z]/;
|
||||
private static _nameRegExp = /^I[A-Z]/;
|
||||
|
||||
readonly meta: eslint.Rule.RuleMetaData = {
|
||||
messages: {
|
||||
|
|
|
@ -7,6 +7,7 @@ import { URI } from 'vs/base/common/uri';
|
|||
import { MainThreadDiaglogsShape, MainContext, MainThreadDialogOpenOptions, MainThreadDialogSaveOptions } from '../common/extHost.protocol';
|
||||
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
|
||||
import { IFileDialogService, IOpenDialogOptions, ISaveDialogOptions } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadDialogs)
|
||||
export class MainThreadDialogs implements MainThreadDiaglogsShape {
|
||||
|
@ -46,7 +47,7 @@ export class MainThreadDialogs implements MainThreadDiaglogsShape {
|
|||
canSelectMany: options?.canSelectMany,
|
||||
defaultUri: options?.defaultUri ? URI.revive(options.defaultUri) : undefined,
|
||||
title: options?.title || undefined,
|
||||
availableFileSystems: []
|
||||
availableFileSystems: options?.allowUIResources ? [Schemas.vscodeRemote, Schemas.file] : []
|
||||
};
|
||||
if (options?.filters) {
|
||||
result.filters = [];
|
||||
|
|
|
@ -679,7 +679,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
|||
return extHostQuickOpen.showInput(options, token);
|
||||
},
|
||||
showOpenDialog(options) {
|
||||
return extHostDialogs.showOpenDialog(options);
|
||||
return extHostDialogs.showOpenDialog(extension, options);
|
||||
},
|
||||
showSaveDialog(options) {
|
||||
return extHostDialogs.showSaveDialog(options);
|
||||
|
|
|
@ -174,6 +174,7 @@ export interface MainThreadDialogOpenOptions {
|
|||
canSelectMany?: boolean;
|
||||
filters?: { [name: string]: string[] };
|
||||
title?: string;
|
||||
allowUIResources?: boolean;
|
||||
}
|
||||
|
||||
export interface MainThreadDialogSaveOptions {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
import type * as vscode from 'vscode';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MainContext, MainThreadDiaglogsShape, IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
export class ExtHostDialogs {
|
||||
|
||||
|
@ -15,7 +17,10 @@ export class ExtHostDialogs {
|
|||
this._proxy = mainContext.getProxy(MainContext.MainThreadDialogs);
|
||||
}
|
||||
|
||||
showOpenDialog(options?: vscode.OpenDialogOptions): Promise<URI[] | undefined> {
|
||||
showOpenDialog(extension: IRelaxedExtensionDescription, options?: vscode.OpenDialogOptions): Promise<URI[] | undefined> {
|
||||
if (options?.allowUIResources) {
|
||||
checkProposedApiEnabled(extension, 'showLocal');
|
||||
}
|
||||
return this._proxy.$showOpenDialog(options).then(filepaths => {
|
||||
return filepaths ? filepaths.map(p => URI.revive(p)) : undefined;
|
||||
});
|
||||
|
|
|
@ -56,6 +56,7 @@ export const allApiProposals = Object.freeze({
|
|||
scmActionButton: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmActionButton.d.ts',
|
||||
scmSelectedProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmSelectedProvider.d.ts',
|
||||
scmValidation: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.scmValidation.d.ts',
|
||||
showLocal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.showLocal.d.ts',
|
||||
tabInputTextMerge: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tabInputTextMerge.d.ts',
|
||||
taskPresentationGroup: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.taskPresentationGroup.d.ts',
|
||||
telemetry: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.telemetry.d.ts',
|
||||
|
|
19
src/vscode-dts/vscode.proposed.showLocal.d.ts
vendored
Normal file
19
src/vscode-dts/vscode.proposed.showLocal.d.ts
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// https://github.com/microsoft/vscode/issues/131138
|
||||
|
||||
declare module 'vscode' {
|
||||
|
||||
export interface OpenDialogOptions {
|
||||
/**
|
||||
* Controls whether the dialog allows users to select local files via the "Show Local" button.
|
||||
* Extensions that set this to `true` should check the scheme of the selected file.
|
||||
* Resources with the `file` scheme come from the same extension host as the extension.
|
||||
* Resources with the `vscode-local` scheme come from an extension host running in the same place as the UI.
|
||||
*/
|
||||
allowUIResources?: boolean;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user