Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)

This commit is contained in:
Anthony Dresser
2019-08-12 21:31:51 -07:00
committed by GitHub
parent 00250839fc
commit 7eba8c4c03
616 changed files with 9472 additions and 7087 deletions

View File

@@ -19,6 +19,7 @@ import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IFileService } from 'vs/platform/files/common/files';
import { isWeb } from 'vs/base/common/platform';
export class FileDialogService implements IFileDialogService {
@@ -90,9 +91,14 @@ export class FileDialogService implements IFileDialogService {
return (schema !== Schemas.file) || (setting === true);
}
private ensureFileSchema(schema: string): string[] {
private addFileSchemaIfNeeded(schema: string): string[] {
// Include File schema unless the schema is web
// Don't allow untitled schema through.
return schema === Schemas.untitled ? [Schemas.file] : (schema !== Schemas.file ? [schema, Schemas.file] : [schema]);
if (isWeb) {
return schema === Schemas.untitled ? [Schemas.file] : [schema];
} else {
return schema === Schemas.untitled ? [Schemas.file] : (schema !== Schemas.file ? [schema, Schemas.file] : [schema]);
}
}
async pickFileFolderAndOpen(options: IPickAndOpenOptions): Promise<any> {
@@ -104,7 +110,7 @@ export class FileDialogService implements IFileDialogService {
if (this.shouldUseSimplified(schema)) {
const title = nls.localize('openFileOrFolder.title', 'Open File Or Folder');
const availableFileSystems = this.ensureFileSchema(schema); // always allow file as well
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
const uri = await this.pickRemoteResource({ canSelectFiles: true, canSelectFolders: true, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
@@ -130,7 +136,7 @@ export class FileDialogService implements IFileDialogService {
if (this.shouldUseSimplified(schema)) {
const title = nls.localize('openFile.title', 'Open File');
const availableFileSystems = this.ensureFileSchema(schema); // always allow file as well
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
const uri = await this.pickRemoteResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
if (uri) {
@@ -152,7 +158,7 @@ export class FileDialogService implements IFileDialogService {
if (this.shouldUseSimplified(schema)) {
const title = nls.localize('openFolder.title', 'Open Folder');
const availableFileSystems = this.ensureFileSchema(schema); // always allow file as well
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
const uri = await this.pickRemoteResource({ canSelectFiles: false, canSelectFolders: true, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
if (uri) {
@@ -175,7 +181,7 @@ export class FileDialogService implements IFileDialogService {
if (this.shouldUseSimplified(schema)) {
const title = nls.localize('openWorkspace.title', 'Open Workspace');
const filters: FileFilter[] = [{ name: nls.localize('filterName.workspace', 'Workspace'), extensions: [WORKSPACE_EXTENSION] }];
const availableFileSystems = this.ensureFileSchema(schema); // always allow file as well
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
const uri = await this.pickRemoteResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, filters, availableFileSystems });
if (uri) {
@@ -192,7 +198,7 @@ export class FileDialogService implements IFileDialogService {
const schema = this.getFileSystemSchema(options);
if (this.shouldUseSimplified(schema)) {
if (!options.availableFileSystems) {
options.availableFileSystems = this.ensureFileSchema(schema); // always allow file as well
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
}
options.title = nls.localize('saveFileAs.title', 'Save As');
@@ -221,7 +227,7 @@ export class FileDialogService implements IFileDialogService {
const schema = this.getFileSystemSchema(options);
if (this.shouldUseSimplified(schema)) {
if (!options.availableFileSystems) {
options.availableFileSystems = this.ensureFileSchema(schema); // always allow file as well
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
}
return this.saveRemoteResource(options);
@@ -239,7 +245,7 @@ export class FileDialogService implements IFileDialogService {
const schema = this.getFileSystemSchema(options);
if (this.shouldUseSimplified(schema)) {
if (!options.availableFileSystems) {
options.availableFileSystems = this.ensureFileSchema(schema); // always allow file as well
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
}
const uri = await this.pickRemoteResource(options);

View File

@@ -46,24 +46,24 @@ enum UpdateResult {
}
export class RemoteFileDialog {
private options: IOpenDialogOptions;
private currentFolder: URI;
private filePickBox: IQuickPick<FileQuickPickItem>;
private hidden: boolean;
private allowFileSelection: boolean;
private allowFolderSelection: boolean;
private options!: IOpenDialogOptions;
private currentFolder!: URI;
private filePickBox!: IQuickPick<FileQuickPickItem>;
private hidden: boolean = false;
private allowFileSelection: boolean = true;
private allowFolderSelection: boolean = false;
private remoteAuthority: string | undefined;
private requiresTrailing: boolean;
private requiresTrailing: boolean = false;
private trailing: string | undefined;
private scheme: string = REMOTE_HOST_SCHEME;
private contextKey: IContextKey<boolean>;
private userEnteredPathSegment: string;
private autoCompletePathSegment: string;
private activeItem: FileQuickPickItem;
private userHome: URI;
private userEnteredPathSegment: string = '';
private autoCompletePathSegment: string = '';
private activeItem: FileQuickPickItem | undefined;
private userHome!: URI;
private badPath: string | undefined;
private remoteAgentEnvironment: IRemoteAgentEnvironment | null;
private separator: string;
private remoteAgentEnvironment: IRemoteAgentEnvironment | null | undefined;
private separator: string = '/';
private onBusyChangeEmitter = new Emitter<boolean>();
private updatingPromise: CancelablePromise<void> | undefined;
@@ -762,8 +762,8 @@ export class RemoteFileDialog {
private pathAppend(uri: URI, additional: string): string {
if ((additional === '..') || (additional === '.')) {
const basePath = this.pathFromUri(uri);
return basePath + this.separator + additional;
const basePath = this.pathFromUri(uri, true);
return basePath + additional;
} else {
return this.pathFromUri(resources.joinPath(uri, additional));
}