提交 8b451a25 编写于 作者: M Matt Bierner

getDescription(), return undefined instead of null

上级 2b078568
......@@ -366,7 +366,7 @@ class ResourceLabelWidget extends IconLabel {
this.setResource({
resource: toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }),
name: withNullAsUndefined(editor.getName()),
description: withNullAsUndefined(editor.getDescription(options ? options.descriptionVerbosity : undefined))
description: editor.getDescription(options ? options.descriptionVerbosity : undefined)
}, options);
}
......
......@@ -51,6 +51,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
import { toLocalResource } from 'vs/base/common/resources';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { withNullAsUndefined } from 'vs/base/common/types';
// Register String Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
......@@ -205,7 +206,7 @@ class SideBySideEditorInputFactory implements IEditorInputFactory {
const masterInput = masterInputFactory.deserialize(instantiationService, deserialized.masterSerialized);
if (detailsInput && masterInput) {
return new SideBySideEditorInput(deserialized.name, deserialized.description, detailsInput, masterInput);
return new SideBySideEditorInput(deserialized.name, withNullAsUndefined(deserialized.description), detailsInput, masterInput);
}
}
......
......@@ -59,7 +59,7 @@ export class EditorPickerEntry extends QuickOpenEntryGroup {
}
getDescription() {
return withNullAsUndefined(this.editor.getDescription());
return this.editor.getDescription();
}
run(mode: Mode, context: IEntryRunContext): boolean {
......
......@@ -725,7 +725,7 @@ export class TabsTitleControl extends TitleControl {
const labels = this.group.editors.map(editor => ({
editor,
name: editor.getName()!,
description: withNullAsUndefined(editor.getDescription(verbosity)),
description: editor.getDescription(verbosity),
title: withNullAsUndefined(editor.getTitle(Verbosity.LONG))
}));
......@@ -778,7 +778,7 @@ export class TabsTitleControl extends TitleControl {
if (useLongDescriptions) {
mapDescriptionToDuplicates.clear();
duplicateTitles.forEach(label => {
label.description = withNullAsUndefined(label.editor.getDescription(Verbosity.LONG));
label.description = label.editor.getDescription(Verbosity.LONG);
getOrSet(mapDescriptionToDuplicates, label.description, []).push(label);
});
}
......
......@@ -745,7 +745,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
if (input instanceof EditorInput) {
this.resource = resourceForEditorHistory(input, fileService);
this.label = types.withNullAsUndefined(input.getName());
this.description = types.withNullAsUndefined(input.getDescription());
this.description = input.getDescription();
this.dirty = input.isDirty();
} else {
const resourceInput = input as IResourceInput;
......
......@@ -295,7 +295,7 @@ export interface IEditorInput extends IDisposable {
/**
* Returns the display description of this input.
*/
getDescription(verbosity?: Verbosity): string | null;
getDescription(verbosity?: Verbosity): string | undefined;
/**
* Returns the display title of this input.
......@@ -364,8 +364,8 @@ export abstract class EditorInput extends Disposable implements IEditorInput {
* Returns the description of this input that can be shown to the user. Examples include showing the description of
* the input above the editor area to the side of the name of the input.
*/
getDescription(verbosity?: Verbosity): string | null {
return null;
getDescription(verbosity?: Verbosity): string | undefined {
return undefined;
}
/**
......@@ -552,7 +552,7 @@ export class SideBySideEditorInput extends EditorInput {
constructor(
private readonly name: string,
private readonly description: string | null,
private readonly description: string | undefined,
private readonly _details: EditorInput,
private readonly _master: EditorInput
) {
......@@ -625,7 +625,7 @@ export class SideBySideEditorInput extends EditorInput {
return this.name;
}
getDescription(): string | null {
getDescription(): string | undefined {
return this.description;
}
......
......@@ -55,8 +55,8 @@ export class DataUriEditorInput extends EditorInput {
return withUndefinedAsNull(this.name);
}
getDescription(): string | null {
return withUndefinedAsNull(this.description);
getDescription(): string | undefined {
return this.description;
}
resolve(): Promise<BinaryEditorModel> {
......
......@@ -18,7 +18,7 @@ export class DiffEditorInput extends SideBySideEditorInput {
private cachedModel: DiffEditorModel | null;
constructor(name: string, description: string | null, original: EditorInput, modified: EditorInput, private readonly forceOpenAsBinary?: boolean) {
constructor(name: string, description: string | undefined, original: EditorInput, modified: EditorInput, private readonly forceOpenAsBinary?: boolean) {
super(name, description, original, modified);
}
......
......@@ -22,7 +22,7 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
constructor(
private name: string,
private description: string | null,
private description: string | undefined,
private readonly resource: URI,
private preferredMode: string | undefined,
@ITextModelService private readonly textModelResolverService: ITextModelService
......@@ -53,7 +53,7 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport {
}
}
getDescription(): string | null {
getDescription(): string | undefined {
return this.description;
}
......
......@@ -77,9 +77,9 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
return this.labelService.getUriLabel(dirname(this.resource));
}
getDescription(verbosity: Verbosity = Verbosity.MEDIUM): string | null {
getDescription(verbosity: Verbosity = Verbosity.MEDIUM): string | undefined {
if (!this.hasAssociatedFilePath) {
return null;
return undefined;
}
switch (verbosity) {
......
......@@ -49,7 +49,7 @@ export class PerfviewInput extends ResourceEditorInput {
) {
super(
localize('name', "Startup Performance"),
null,
undefined,
PerfviewInput.Uri,
undefined,
textModelResolverService
......
......@@ -130,7 +130,7 @@ export class WebviewEditorInput<State = any> extends EditorInput {
}
public getDescription() {
return null;
return undefined;
}
public setName(value: string): void {
......
......@@ -27,7 +27,7 @@ import { isCodeEditor, isDiffEditor, ICodeEditor, IDiffEditor } from 'vs/editor/
import { IEditorGroupView, IEditorOpeningEvent, EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { ILabelService } from 'vs/platform/label/common/label';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { withNullAsUndefined, withUndefinedAsNull } from 'vs/base/common/types';
import { withNullAsUndefined } from 'vs/base/common/types';
type ICachedEditorInput = ResourceEditorInput | IFileEditorInput | DataUriEditorInput;
......@@ -524,7 +524,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
const rightInput = this.createInput({ resource: resourceDiffInput.rightResource, forceFile: resourceDiffInput.forceFile });
const label = resourceDiffInput.label || localize('compareLabels', "{0} ↔ {1}", this.toDiffLabel(leftInput), this.toDiffLabel(rightInput));
return new DiffEditorInput(label, withUndefinedAsNull(resourceDiffInput.description), leftInput, rightInput);
return new DiffEditorInput(label, resourceDiffInput.description, leftInput, rightInput);
}
// Untitled file support
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册