提交 641adcca 编写于 作者: A Alex Ross

Fix strict null from dialog change

上级 d5e86e79
......@@ -331,7 +331,7 @@ export class RemoteFileDialogService extends FileDialogService {
super(windowService, contextService, historyService, environmentService, instantiationService);
}
public showSaveDialog(options: ISaveDialogOptions): Promise<URI> {
public showSaveDialog(options: ISaveDialogOptions): Promise<URI | undefined> {
const defaultUri = options.defaultUri;
if (defaultUri && defaultUri.scheme === REMOTE_HOST_SCHEME) {
return this.showSaveRemoteDialog(options);
......
......@@ -35,7 +35,7 @@ export class RemoteFileDialog {
private filePickBox: IQuickPick<FileQuickPickItem>;
private allowFileSelection: boolean;
private allowFolderSelection: boolean;
private remoteAuthority: string;
private remoteAuthority: string | undefined;
constructor(
@IFileService private readonly remoteFileService: RemoteFileService,
......@@ -49,10 +49,10 @@ export class RemoteFileDialog {
this.remoteAuthority = this.windowService.getConfiguration().remoteAuthority;
}
public async showOpenDialog(options: IOpenDialogOptions = {}): Promise<undefined> {
public async showOpenDialog(options: IOpenDialogOptions = {}): Promise<void> {
if (!this.remoteAuthority) {
this.notificationService.info(nls.localize('remoteFileDialog.notConnectedToRemote', 'Not connected to a remote.'));
return Promise.resolve(undefined);
return Promise.resolve();
}
const defaultUri = options.defaultUri ? options.defaultUri : URI.from({ scheme: REMOTE_HOST_SCHEME, authority: this.remoteAuthority, path: '/' });
const title = nls.localize('remoteFileDialog.openTitle', 'Open File or Folder');
......@@ -63,11 +63,11 @@ export class RemoteFileDialog {
return this.windowService.openWindow([{ uri: fileFolderUri, typeHint: 'folder' }]);
} else {
return this.editorService.openEditor({ resource: fileFolderUri }).then(() => {
return Promise.resolve(undefined);
return Promise.resolve();
});
}
}
return Promise.resolve(undefined);
return Promise.resolve();
});
}
......@@ -206,18 +206,20 @@ export class RemoteFileDialog {
}
}
private updateItems(newFolder: URI) {
this.currentFolder = newFolder;
this.filePickBox.placeholder = this.labelService.getUriLabel(newFolder, { endWithSeparator: true });
this.filePickBox.value = '';
this.filePickBox.busy = true;
this.createItems(this.currentFolder).then(items => {
this.filePickBox.items = items;
if (this.allowFolderSelection) {
this.filePickBox.activeItems = [];
}
this.filePickBox.busy = false;
});
private updateItems(newFolder: URI | null) {
if (newFolder) {
this.currentFolder = newFolder;
this.filePickBox.placeholder = this.labelService.getUriLabel(newFolder, { endWithSeparator: true });
this.filePickBox.value = '';
this.filePickBox.busy = true;
this.createItems(this.currentFolder).then(items => {
this.filePickBox.items = items;
if (this.allowFolderSelection) {
this.filePickBox.activeItems = [];
}
this.filePickBox.busy = false;
});
}
}
private isValidBaseName(name: string): boolean {
......@@ -255,14 +257,14 @@ export class RemoteFileDialog {
private basenameWithTrailingSlash(fullPath: URI): string {
const child = this.labelService.getUriLabel(fullPath, { endWithSeparator: true });
const parent = this.labelService.getUriLabel(resources.dirname(fullPath), { endWithSeparator: true });
const parent = this.labelService.getUriLabel(resources.dirname(fullPath)!, { endWithSeparator: true });
return child.substring(parent.length);
}
private createBackItem(currFolder: URI): FileQuickPickItem | null {
const parentFolder = resources.dirname(currFolder);
const parentFolder = resources.dirname(currFolder)!;
if (!resources.isEqual(currFolder, parentFolder)) {
return { label: '..', uri: resources.dirname(currFolder), isFolder: true };
return { label: '..', uri: resources.dirname(currFolder)!, isFolder: true };
}
return null;
}
......
......@@ -213,7 +213,7 @@ export class RemoteFileService extends FileService {
return resource.scheme === Schemas.file || this._provider.has(resource.scheme);
}
private _tryParseFileOperationResult(err: any): FileOperationResult {
private _tryParseFileOperationResult(err: any): FileOperationResult | undefined {
if (!(err instanceof Error)) {
return undefined;
}
......
......@@ -136,27 +136,25 @@ export class LabelService implements ILabelService {
return getPathLabel(resource.path, this.environmentService, options.relative ? this.contextService : undefined);
}
let label: string;
if (options.relative) {
const baseResource = this.contextService && this.contextService.getWorkspaceFolder(resource);
if (baseResource) {
let relativeLabel: string;
if (isEqual(baseResource.uri, resource, !isLinux)) {
relativeLabel = ''; // no label if resources are identical
} else {
const baseResourceLabel = this.formatUri(baseResource.uri, formatting, options.noPrefix);
relativeLabel = ltrim(this.formatUri(resource, formatting, options.noPrefix).substring(baseResourceLabel.length), formatting.separator);
}
const hasMultipleRoots = this.contextService.getWorkspace().folders.length > 1;
if (hasMultipleRoots && !options.noPrefix) {
const rootName = (baseResource && baseResource.name) ? baseResource.name : basenameOrAuthority(baseResource.uri);
relativeLabel = relativeLabel ? (rootName + '' + relativeLabel) : rootName; // always show root basename if there are multiple
}
let label: string | undefined;
const baseResource = this.contextService && this.contextService.getWorkspaceFolder(resource);
if (options.relative && baseResource) {
let relativeLabel: string;
if (isEqual(baseResource.uri, resource, !isLinux)) {
relativeLabel = ''; // no label if resources are identical
} else {
const baseResourceLabel = this.formatUri(baseResource.uri, formatting, options.noPrefix);
relativeLabel = ltrim(this.formatUri(resource, formatting, options.noPrefix).substring(baseResourceLabel.length), formatting.separator);
}
label = relativeLabel;
const hasMultipleRoots = this.contextService.getWorkspace().folders.length > 1;
if (hasMultipleRoots && !options.noPrefix) {
const rootName = (baseResource && baseResource.name) ? baseResource.name : basenameOrAuthority(baseResource.uri);
relativeLabel = relativeLabel ? (rootName + '' + relativeLabel) : rootName; // always show root basename if there are multiple
}
label = relativeLabel;
} else {
label = this.formatUri(resource, formatting, options.noPrefix);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册