Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)

* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998

* fix pipelines

* fix strict-null-checks

* add missing files
This commit is contained in:
Anthony Dresser
2019-10-21 22:12:22 -07:00
committed by GitHub
parent 7c9be74970
commit 1e22f47304
913 changed files with 18898 additions and 16536 deletions

View File

@@ -93,7 +93,7 @@ export abstract class AbstractFileDialogService {
if (stat.isDirectory || options.forceNewWindow || preferNewWindow) {
return this.hostService.openWindow([toOpen], { forceNewWindow: options.forceNewWindow });
} else {
return this.openerService.open(uri);
return this.openerService.open(uri, { fromUserGesture: true });
}
}
}
@@ -107,7 +107,7 @@ export abstract class AbstractFileDialogService {
if (options.forceNewWindow || preferNewWindow) {
return this.hostService.openWindow([{ fileUri: uri }], { forceNewWindow: options.forceNewWindow });
} else {
return this.openerService.open(uri);
return this.openerService.open(uri, { fromUserGesture: true });
}
}
}

View File

@@ -129,7 +129,7 @@ export class DialogService implements IDialogService {
navigator.userAgent
);
const { choice } = await this.show(Severity.Info, this.productService.nameLong, [nls.localize('copy', "Copy"), nls.localize('ok', "OK")], { detail });
const { choice } = await this.show(Severity.Info, this.productService.nameLong, [nls.localize('copy', "Copy"), nls.localize('ok', "OK")], { detail, cancelId: 1 });
if (choice === 0) {
this.clipboardService.writeText(detail);

View File

@@ -35,6 +35,7 @@ import { ICommandHandler } from 'vs/platform/commands/common/commands';
import { ITextFileService, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { toResource } from 'vs/workbench/common/editor';
import { normalizeDriveLetter } from 'vs/base/common/labels';
export namespace OpenLocalFileCommand {
export const ID = 'workbench.action.files.openLocalFile';
@@ -255,16 +256,6 @@ export class SimpleFileDialog {
homedir = resources.dirname(this.options.defaultUri);
this.trailing = resources.basename(this.options.defaultUri);
}
// append extension
if (isSave && !ext && this.options.filters) {
for (let i = 0; i < this.options.filters.length; i++) {
if (this.options.filters[i].extensions[0] !== '*') {
ext = '.' + this.options.filters[i].extensions[0];
this.trailing = this.trailing ? this.trailing + ext : ext;
break;
}
}
}
}
return new Promise<URI | undefined>(async (resolve) => {
@@ -486,7 +477,7 @@ export class SimpleFileDialog {
const newPath = this.pathFromUri(item.uri);
if (startsWithIgnoreCase(newPath, this.filePickBox.value) && (equalsIgnoreCase(item.label, resources.basename(item.uri)))) {
this.filePickBox.valueSelection = [this.pathFromUri(this.currentFolder).length, this.filePickBox.value.length];
this.insertText(newPath, item.label);
this.insertText(newPath, this.basenameWithTrailingSlash(item.uri));
} else if ((item.label === '..') && startsWithIgnoreCase(this.filePickBox.value, newPath)) {
this.filePickBox.valueSelection = [newPath.length, this.filePickBox.value.length];
this.insertText(newPath, '');
@@ -602,7 +593,7 @@ export class SimpleFileDialog {
this.autoCompletePathSegment = '';
return false;
}
const itemBasename = this.trimTrailingSlash(quickPickItem.label);
const itemBasename = quickPickItem.label;
// Either force the autocomplete, or the old value should be one smaller than the new value and match the new value.
if (itemBasename === '..') {
// Don't match on the up directory item ever.
@@ -621,7 +612,7 @@ export class SimpleFileDialog {
this.autoCompletePathSegment = '';
this.filePickBox.activeItems = [quickPickItem];
return true;
} else if (force && (!equalsIgnoreCase(quickPickItem.label, (this.userEnteredPathSegment + this.autoCompletePathSegment)))) {
} else if (force && (!equalsIgnoreCase(this.basenameWithTrailingSlash(quickPickItem.uri), (this.userEnteredPathSegment + this.autoCompletePathSegment)))) {
this.userEnteredPathSegment = '';
this.autoCompletePathSegment = this.trimTrailingSlash(itemBasename);
this.activeItem = quickPickItem;
@@ -807,7 +798,7 @@ export class SimpleFileDialog {
}
private pathFromUri(uri: URI, endWithSeparator: boolean = false): string {
let result: string = uri.fsPath.replace(/\n/g, '');
let result: string = normalizeDriveLetter(uri.fsPath).replace(/\n/g, '');
if (this.separator === '/') {
result = result.replace(/\\/g, this.separator);
} else {
@@ -848,7 +839,7 @@ export class SimpleFileDialog {
}
private createBackItem(currFolder: URI): FileQuickPickItem | null {
const parentFolder = resources.dirname(currFolder)!;
const parentFolder = resources.dirname(currFolder);
if (!resources.isEqual(currFolder, parentFolder, true)) {
return { label: '..', uri: resources.addTrailingPathSeparator(parentFolder, this.separator), isFolder: true };
}
@@ -913,7 +904,7 @@ export class SimpleFileDialog {
try {
const stat = await this.fileService.resolve(fullPath);
if (stat.isDirectory) {
filename = this.basenameWithTrailingSlash(fullPath);
filename = resources.basename(fullPath);
fullPath = resources.addTrailingPathSeparator(fullPath, this.separator);
return { label: filename, uri: fullPath, isFolder: true, iconClasses: getIconClasses(this.modelService, this.modeService, fullPath || undefined, FileKind.FOLDER) };
} else if (!stat.isDirectory && this.allowFileSelection && this.filterFile(fullPath)) {

View File

@@ -43,10 +43,11 @@ export class DialogService implements IDialogService {
_serviceBrand: undefined;
private impl: IDialogService;
private nativeImpl: IDialogService;
private customImpl: IDialogService;
constructor(
@IConfigurationService configurationService: IConfigurationService,
@IConfigurationService private configurationService: IConfigurationService,
@ILogService logService: ILogService,
@ILayoutService layoutService: ILayoutService,
@IThemeService themeService: IThemeService,
@@ -56,27 +57,32 @@ export class DialogService implements IDialogService {
@IClipboardService clipboardService: IClipboardService,
@IElectronService electronService: IElectronService
) {
this.customImpl = new HTMLDialogService(logService, layoutService, themeService, keybindingService, productService, clipboardService);
this.nativeImpl = new NativeDialogService(logService, sharedProcessService, electronService, clipboardService);
}
// Use HTML based dialogs
if (configurationService.getValue('workbench.dialogs.customEnabled') === true) {
this.impl = new HTMLDialogService(logService, layoutService, themeService, keybindingService, productService, clipboardService);
}
// Electron dialog service
else {
this.impl = new NativeDialogService(logService, sharedProcessService, electronService, clipboardService);
}
private get useCustomDialog(): boolean {
return this.configurationService.getValue('workbench.dialogs.customEnabled') === true;
}
confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
return this.impl.confirm(confirmation);
if (this.useCustomDialog) {
return this.customImpl.confirm(confirmation);
}
return this.nativeImpl.confirm(confirmation);
}
show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions | undefined): Promise<IShowResult> {
return this.impl.show(severity, message, buttons, options);
if (this.useCustomDialog) {
return this.customImpl.show(severity, message, buttons, options);
}
return this.nativeImpl.show(severity, message, buttons, options);
}
about(): Promise<void> {
return this.impl.about();
return this.nativeImpl.about();
}
}

View File

@@ -46,8 +46,8 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
private shouldUseSimplified(schema: string): { useSimplified: boolean, isSetting: boolean } {
const setting = (this.configurationService.getValue('files.simpleDialog.enable') === true);
return { useSimplified: (schema !== Schemas.file) || setting, isSetting: (schema === Schemas.file) && setting };
const newWindowSetting = (this.configurationService.getValue('window.openFilesInNewWindow') === 'on');
return { useSimplified: (schema !== Schemas.file) || setting, isSetting: newWindowSetting };
}
async pickFileFolderAndOpen(options: IPickAndOpenOptions): Promise<any> {
@@ -110,7 +110,7 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
return this.pickFileToSaveSimplified(schema, options);
} else {
const result = await this.electronService.showSaveDialog(this.toNativeSaveDialogOptions(options));
if (result && result.filePath) {
if (result && !result.canceled && result.filePath) {
return URI.file(result.filePath);
}
}
@@ -134,7 +134,7 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
}
const result = await this.electronService.showSaveDialog(this.toNativeSaveDialogOptions(options));
if (result && result.filePath) {
if (result && !result.canceled && result.filePath) {
return URI.file(result.filePath);
}
@@ -149,7 +149,7 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
const defaultUri = options.defaultUri;
const newOptions: OpenDialogOptions = {
const newOptions: OpenDialogOptions & { properties: string[] } = {
title: options.title,
defaultPath: defaultUri && defaultUri.fsPath,
buttonLabel: options.openLabel,
@@ -157,18 +157,18 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
properties: []
};
newOptions.properties!.push('createDirectory');
newOptions.properties.push('createDirectory');
if (options.canSelectFiles) {
newOptions.properties!.push('openFile');
newOptions.properties.push('openFile');
}
if (options.canSelectFolders) {
newOptions.properties!.push('openDirectory');
newOptions.properties.push('openDirectory');
}
if (options.canSelectMany) {
newOptions.properties!.push('multiSelections');
newOptions.properties.push('multiSelections');
}
const result = await this.electronService.showOpenDialog(newOptions);