diff --git a/src/vs/platform/dialogs/common/dialogs.ts b/src/vs/platform/dialogs/common/dialogs.ts index 25e49ef1c2e..08c1a23a165 100644 --- a/src/vs/platform/dialogs/common/dialogs.ts +++ b/src/vs/platform/dialogs/common/dialogs.ts @@ -100,6 +100,7 @@ export interface IPickAndOpenOptions { defaultUri?: URI; telemetryExtraData?: ITelemetryData; availableFileSystems?: string[]; + remoteAuthority?: string | null; } export interface ISaveDialogOptions { diff --git a/src/vs/workbench/browser/actions/workspaceCommands.ts b/src/vs/workbench/browser/actions/workspaceCommands.ts index de53f627f2a..7466211635f 100644 --- a/src/vs/workbench/browser/actions/workspaceCommands.ts +++ b/src/vs/workbench/browser/actions/workspaceCommands.ts @@ -17,7 +17,7 @@ import { IQuickInputService, IPickOptions, IQuickPickItem } from 'vs/platform/qu import { getIconClasses } from 'vs/editor/common/services/getIconClasses'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService } from 'vs/editor/common/services/modeService'; -import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs'; +import { IFileDialogService, IPickAndOpenOptions } from 'vs/platform/dialogs/common/dialogs'; import { URI } from 'vs/base/common/uri'; import { Schemas } from 'vs/base/common/network'; import { IOpenWindowOptions, IWindowOpenable } from 'vs/platform/windows/common/windows'; @@ -130,21 +130,26 @@ interface IOpenFolderAPICommandOptions { forceNewWindow?: boolean; forceReuseWindow?: boolean; noRecentEntry?: boolean; + remoteAuthority?: string; } CommandsRegistry.registerCommand({ id: 'vscode.openFolder', handler: (accessor: ServicesAccessor, uri?: URI, arg?: boolean | IOpenFolderAPICommandOptions) => { const commandService = accessor.get(ICommandService); - // Be compatible to previous args by converting to options if (typeof arg === 'boolean') { arg = { forceNewWindow: arg }; } - // Without URI, ask to pick a folder or workpsace to open + // Without URI, ask to pick a folder or workspace to open if (!uri) { - return commandService.executeCommand('_files.pickFolderAndOpen', { forceNewWindow: arg?.forceNewWindow }); + const options: IPickAndOpenOptions = { + forceNewWindow: arg?.forceNewWindow, + availableFileSystems: arg?.remoteAuthority === null ? [Schemas.file] : undefined, + remoteAuthority: arg?.remoteAuthority + }; + return commandService.executeCommand('_files.pickFolderAndOpen', options); } uri = URI.revive(uri); @@ -152,7 +157,8 @@ CommandsRegistry.registerCommand({ const options: IOpenWindowOptions = { forceNewWindow: arg?.forceNewWindow, forceReuseWindow: arg?.forceReuseWindow, - noRecentEntry: arg?.noRecentEntry + noRecentEntry: arg?.noRecentEntry, + remoteAuthority: arg?.remoteAuthority }; const uriToOpen: IWindowOpenable = (hasWorkspaceFileExtension(uri) || uri.scheme === Schemas.untitled) ? { workspaceUri: uri } : { folderUri: uri }; @@ -161,8 +167,19 @@ CommandsRegistry.registerCommand({ description: { description: 'Open a folder or workspace in the current window or new window depending on the newWindow argument. Note that opening in the same window will shutdown the current extension host process and start a new one on the given folder/workspace unless the newWindow parameter is set to true.', args: [ - { name: 'uri', description: '(optional) Uri of the folder or workspace file to open. If not provided, a native dialog will ask the user for the folder', constraint: (value: any) => value === undefined || value instanceof URI }, - { name: 'options', description: '(optional) Options. Object with the following properties: `forceNewWindow `: Whether to open the folder/workspace in a new window or the same. Defaults to opening in the same window. `noRecentEntry`: Whether the opened URI will appear in the \'Open Recent\' list. Defaults to true. Note, for backward compatibility, options can also be of type boolean, representing the `forceNewWindow` setting.', constraint: (value: any) => value === undefined || typeof value === 'object' || typeof value === 'boolean' } + { + name: 'uri', description: '(optional) Uri of the folder or workspace file to open. If not provided, a native dialog will ask the user for the folder', + constraint: (value: any) => value === undefined || value === null || value instanceof URI + }, + { + name: 'options', + description: '(optional) Options. Object with the following properties: ' + + '`forceNewWindow`: Whether to open the folder/workspace in a new window or the same. Defaults to opening in the same window. ' + + '`forceReuseWindow`: Whether to force opening the folder/workspace in the same window. Defaults to false. ' + + '`noRecentEntry`: Whether the opened URI will appear in the \'Open Recent\' list. Defaults to false. ' + + 'Note, for backward compatibility, options can also be of type boolean, representing the `forceNewWindow` setting.', + constraint: (value: any) => value === undefined || typeof value === 'object' || typeof value === 'boolean' + } ] } }); diff --git a/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts b/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts index 268b195ef82..e488e6df16a 100644 --- a/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts +++ b/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts @@ -163,7 +163,7 @@ export abstract class AbstractFileDialogService implements IFileDialogService { } if (stat.isDirectory || options.forceNewWindow || preferNewWindow) { - return this.hostService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow }); + return this.hostService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority }); } else { return this.openerService.open(uri, { fromUserGesture: true, editorOptions: { pinned: true } }); } @@ -180,7 +180,7 @@ export abstract class AbstractFileDialogService implements IFileDialogService { this.workspacesService.addRecentlyOpened([{ fileUri: uri, label: this.labelService.getUriLabel(uri) }]); if (options.forceNewWindow || preferNewWindow) { - return this.hostService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow }); + return this.hostService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority }); } else { return this.openerService.open(uri, { fromUserGesture: true, editorOptions: { pinned: true } }); } @@ -193,7 +193,7 @@ export abstract class AbstractFileDialogService implements IFileDialogService { const uri = await this.pickResource({ canSelectFiles: false, canSelectFolders: true, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems }); if (uri) { - return this.hostService.openWindow([{ folderUri: uri }], { forceNewWindow: options.forceNewWindow }); + return this.hostService.openWindow([{ folderUri: uri }], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority }); } } @@ -204,7 +204,7 @@ export abstract class AbstractFileDialogService implements IFileDialogService { const uri = await this.pickResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, filters, availableFileSystems }); if (uri) { - return this.hostService.openWindow([{ workspaceUri: uri }], { forceNewWindow: options.forceNewWindow }); + return this.hostService.openWindow([{ workspaceUri: uri }], { forceNewWindow: options.forceNewWindow, remoteAuthority: options.remoteAuthority }); } }