diff --git a/.eslintplugin/vscode-dts-interface-naming.ts b/.eslintplugin/vscode-dts-interface-naming.ts index d9ec4e8c34c..59112bcb29d 100644 --- a/.eslintplugin/vscode-dts-interface-naming.ts +++ b/.eslintplugin/vscode-dts-interface-naming.ts @@ -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: { diff --git a/src/vs/workbench/api/browser/mainThreadDialogs.ts b/src/vs/workbench/api/browser/mainThreadDialogs.ts index e9ca6d75502..3ac34ea6b7b 100644 --- a/src/vs/workbench/api/browser/mainThreadDialogs.ts +++ b/src/vs/workbench/api/browser/mainThreadDialogs.ts @@ -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 = []; diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index c33c3e72bfe..27edca9fa34 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -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); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 32078f50af6..414c984240f 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -174,6 +174,7 @@ export interface MainThreadDialogOpenOptions { canSelectMany?: boolean; filters?: { [name: string]: string[] }; title?: string; + allowUIResources?: boolean; } export interface MainThreadDialogSaveOptions { diff --git a/src/vs/workbench/api/common/extHostDialogs.ts b/src/vs/workbench/api/common/extHostDialogs.ts index 69de2a3e7f8..c33cb0704dd 100644 --- a/src/vs/workbench/api/common/extHostDialogs.ts +++ b/src/vs/workbench/api/common/extHostDialogs.ts @@ -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 { + showOpenDialog(extension: IRelaxedExtensionDescription, options?: vscode.OpenDialogOptions): Promise { + if (options?.allowUIResources) { + checkProposedApiEnabled(extension, 'showLocal'); + } return this._proxy.$showOpenDialog(options).then(filepaths => { return filepaths ? filepaths.map(p => URI.revive(p)) : undefined; }); diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 8468acd74d6..8929645d6dd 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -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', diff --git a/src/vscode-dts/vscode.proposed.showLocal.d.ts b/src/vscode-dts/vscode.proposed.showLocal.d.ts new file mode 100644 index 00000000000..9a9294f596b --- /dev/null +++ b/src/vscode-dts/vscode.proposed.showLocal.d.ts @@ -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; + } +}