Skip to content

Commit

Permalink
allowUIResources API proposal
Browse files Browse the repository at this point in the history
Part of #131138
  • Loading branch information
alexr00 committed Feb 8, 2023
1 parent 6876123 commit 3fd3953
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .eslintplugin/vscode-dts-interface-naming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/api/browser/mainThreadDialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.file, Schemas.vscodeRemote] : []
};
if (options?.filters) {
result.filters = [];
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export interface MainThreadDialogOpenOptions {
canSelectMany?: boolean;
filters?: { [name: string]: string[] };
title?: string;
allowUIResources?: boolean;
}

export interface MainThreadDialogSaveOptions {
Expand Down
7 changes: 6 additions & 1 deletion src/vs/workbench/api/common/extHostDialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
});
Expand Down
6 changes: 3 additions & 3 deletions src/vscode-dts/vscode.proposed.showLocal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ declare module 'vscode' {
/**
* 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.
*
* TODO: Workspace extensions already get only `file` scheme URIs back from the dialog. How will we tell the extension that the file is local?
* Resources with the `file` scheme come from the same extension host as the extension.
* Resources with the `vscode-remote` scheme come from a different extension host.
*/
allowLocal?: boolean;
allowUIResources?: boolean;
}
}

0 comments on commit 3fd3953

Please sign in to comment.