Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

View File

@@ -20,10 +20,11 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IFileService } from 'vs/platform/files/common/files';
import { isWeb } from 'vs/base/common/platform';
import { IOpenerService } from 'vs/platform/opener/common/opener';
export class FileDialogService implements IFileDialogService {
_serviceBrand: any;
_serviceBrand: undefined;
constructor(
@IWindowService private readonly windowService: IWindowService,
@@ -32,7 +33,8 @@ export class FileDialogService implements IFileDialogService {
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IFileService private readonly fileService: IFileService
@IFileService private readonly fileService: IFileService,
@IOpenerService private readonly openerService: IOpenerService
) { }
defaultFilePath(schemeFilter = this.getSchemeFilterForWindow()): URI | undefined {
@@ -85,10 +87,10 @@ export class FileDialogService implements IFileDialogService {
};
}
private shouldUseSimplified(schema: string): boolean {
const setting = this.configurationService.getValue('files.simpleDialog.enable');
private shouldUseSimplified(schema: string): { useSimplified: boolean, isSetting: boolean } {
const setting = (this.configurationService.getValue('files.simpleDialog.enable') === true);
return (schema !== Schemas.file) || (setting === true);
return { useSimplified: (schema !== Schemas.file) || setting, isSetting: (schema === Schemas.file) && setting };
}
private addFileSchemaIfNeeded(schema: string): string[] {
@@ -108,7 +110,8 @@ export class FileDialogService implements IFileDialogService {
options.defaultUri = this.defaultFilePath(schema);
}
if (this.shouldUseSimplified(schema)) {
const shouldUseSimplified = this.shouldUseSimplified(schema);
if (shouldUseSimplified.useSimplified) {
const title = nls.localize('openFileOrFolder.title', 'Open File Or Folder');
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
@@ -118,7 +121,11 @@ export class FileDialogService implements IFileDialogService {
const stat = await this.fileService.resolve(uri);
const toOpen: IURIToOpen = stat.isDirectory ? { folderUri: uri } : { fileUri: uri };
return this.windowService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow });
if (stat.isDirectory || options.forceNewWindow || shouldUseSimplified.isSetting) {
return this.windowService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow });
} else {
return this.openerService.open(uri);
}
}
return;
@@ -134,13 +141,18 @@ export class FileDialogService implements IFileDialogService {
options.defaultUri = this.defaultFilePath(schema);
}
if (this.shouldUseSimplified(schema)) {
const shouldUseSimplified = this.shouldUseSimplified(schema);
if (shouldUseSimplified.useSimplified) {
const title = nls.localize('openFile.title', 'Open File');
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
const uri = await this.pickRemoteResource({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, defaultUri: options.defaultUri, title, availableFileSystems });
if (uri) {
return this.windowService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow });
if (options.forceNewWindow || shouldUseSimplified.isSetting) {
return this.windowService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow });
} else {
return this.openerService.open(uri);
}
}
return;
@@ -156,7 +168,7 @@ export class FileDialogService implements IFileDialogService {
options.defaultUri = this.defaultFolderPath(schema);
}
if (this.shouldUseSimplified(schema)) {
if (this.shouldUseSimplified(schema).useSimplified) {
const title = nls.localize('openFolder.title', 'Open Folder');
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
@@ -178,7 +190,7 @@ export class FileDialogService implements IFileDialogService {
options.defaultUri = this.defaultWorkspacePath(schema);
}
if (this.shouldUseSimplified(schema)) {
if (this.shouldUseSimplified(schema).useSimplified) {
const title = nls.localize('openWorkspace.title', 'Open Workspace');
const filters: FileFilter[] = [{ name: nls.localize('filterName.workspace', 'Workspace'), extensions: [WORKSPACE_EXTENSION] }];
const availableFileSystems = this.addFileSchemaIfNeeded(schema);
@@ -196,7 +208,7 @@ export class FileDialogService implements IFileDialogService {
async pickFileToSave(options: ISaveDialogOptions): Promise<URI | undefined> {
const schema = this.getFileSystemSchema(options);
if (this.shouldUseSimplified(schema)) {
if (this.shouldUseSimplified(schema).useSimplified) {
if (!options.availableFileSystems) {
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
}
@@ -225,7 +237,7 @@ export class FileDialogService implements IFileDialogService {
async showSaveDialog(options: ISaveDialogOptions): Promise<URI | undefined> {
const schema = this.getFileSystemSchema(options);
if (this.shouldUseSimplified(schema)) {
if (this.shouldUseSimplified(schema).useSimplified) {
if (!options.availableFileSystems) {
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
}
@@ -243,7 +255,7 @@ export class FileDialogService implements IFileDialogService {
async showOpenDialog(options: IOpenDialogOptions): Promise<URI[] | undefined> {
const schema = this.getFileSystemSchema(options);
if (this.shouldUseSimplified(schema)) {
if (this.shouldUseSimplified(schema).useSimplified) {
if (!options.availableFileSystems) {
options.availableFileSystems = this.addFileSchemaIfNeeded(schema);
}