From 5a16d6e6176d4ed37539ee9ef1d66f67770371f4 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 5 Sep 2019 15:56:28 +0200 Subject: [PATCH] Respect scheme of defaultUri in remote file picker Fixes https://github.com/microsoft/vscode-remote-release/issues/1271 --- .../services/dialogs/browser/remoteFileDialog.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts b/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts index 28fb4787d24..9354baad058 100644 --- a/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts +++ b/src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts @@ -101,7 +101,7 @@ export class RemoteFileDialog { } public async showOpenDialog(options: IOpenDialogOptions = {}): Promise { - this.scheme = this.getScheme(options.availableFileSystems); + this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri); this.userHome = await this.getUserHome(); const newOptions = await this.getOptions(options); if (!newOptions) { @@ -112,7 +112,7 @@ export class RemoteFileDialog { } public async showSaveDialog(options: ISaveDialogOptions): Promise { - this.scheme = this.getScheme(options.availableFileSystems); + this.scheme = this.getScheme(options.availableFileSystems, options.defaultUri); this.userHome = await this.getUserHome(); this.requiresTrailing = true; const newOptions = await this.getOptions(options, true); @@ -157,8 +157,14 @@ export class RemoteFileDialog { return resources.toLocalResource(URI.from({ scheme: this.scheme, path }), this.scheme === Schemas.file ? undefined : this.remoteAuthority); } - private getScheme(available: string[] | undefined): string { - return available ? available[0] : Schemas.file; + private getScheme(available: string[] | undefined, defaultUri: URI | undefined): string { + if (available) { + if (defaultUri && (available.indexOf(defaultUri.scheme) >= 0)) { + return defaultUri.scheme; + } + return available[0]; + } + return Schemas.file; } private async getRemoteAgentEnvironment(): Promise { @@ -215,7 +221,7 @@ export class RemoteFileDialog { this.filePickBox.autoFocusOnList = false; this.filePickBox.ignoreFocusOut = true; this.filePickBox.ok = true; - if (this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) { + if ((this.scheme !== Schemas.file) && this.options && this.options.availableFileSystems && (this.options.availableFileSystems.length > 1) && (this.options.availableFileSystems.indexOf(Schemas.file) > -1)) { this.filePickBox.customButton = true; this.filePickBox.customLabel = nls.localize('remoteFileDialog.local', 'Show Local'); let action; -- GitLab