提交 7d715621 编写于 作者: B Benjamin Pasero

untitled - fix title for labels (#89921)

上级 0b02e61f
......@@ -353,7 +353,7 @@ class ResourceLabelWidget extends IconLabel {
this.setResource({ resource, name, description }, options);
}
setResource(label: IResourceLabelProps, options?: IResourceLabelOptions): void {
setResource(label: IResourceLabelProps, options: IResourceLabelOptions = Object.create(null)): void {
if (label.resource?.scheme === Schemas.untitled) {
// Untitled labels are very dynamic because they may change
// whenever the content changes (unless a path is associated).
......@@ -369,19 +369,20 @@ class ResourceLabelWidget extends IconLabel {
}
if (typeof label.description === 'string') {
let untitledDescription: string;
if (untitledModel.hasAssociatedFilePath) {
untitledDescription = this.labelService.getUriLabel(dirname(untitledModel.resource), { relative: true });
} else {
untitledDescription = untitledModel.resource.path;
}
let untitledDescription = untitledModel.resource.path;
if (label.name !== untitledDescription) {
label.description = untitledDescription;
} else if (label.description === posix.sep) {
label.description = undefined; // unset showing just "/" for untitled without associated resource
}
}
let untitledTitle = untitledModel.resource.path;
if (untitledModel.name !== untitledTitle) {
options.title = `${untitledModel.name}${untitledTitle}`;
} else {
options.title = untitledTitle;
}
}
}
......
......@@ -13,6 +13,7 @@ import { ITextModel } from 'vs/editor/common/model';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
suite('Workbench editor model', () => {
let instantiationService: IInstantiationService;
let accessor: TestServiceAccessor;
......
......@@ -13,6 +13,7 @@ import { snapshotToString } from 'vs/workbench/services/textfile/common/textfile
import { ModesRegistry, PLAINTEXT_MODE_ID } from 'vs/editor/common/modes/modesRegistry';
suite('Resource text editors', () => {
let instantiationService: IInstantiationService;
let accessor: TestServiceAccessor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册