Skip to content

Commit e206af1

Browse files
committed
editor input description append file name when custom label used
1 parent 3cbe3b0 commit e206af1

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/vs/workbench/common/editor/resourceEditorInput.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,14 @@ export abstract class AbstractResourceEditorInput extends EditorInput implements
9595
}
9696
}
9797

98+
private getCustomLabel(): string | undefined {
99+
return this.customEditorLabelService.getName(this._preferredResource);
100+
}
101+
98102
private _name: string | undefined = undefined;
99103
override getName(): string {
100104
if (typeof this._name !== 'string') {
101-
this._name = this.customEditorLabelService.getName(this._preferredResource) ?? this.labelService.getUriBasenameLabel(this._preferredResource);
105+
this._name = this.getCustomLabel() ?? this.labelService.getUriBasenameLabel(this._preferredResource);
102106
}
103107

104108
return this._name;
@@ -116,10 +120,14 @@ export abstract class AbstractResourceEditorInput extends EditorInput implements
116120
}
117121
}
118122

123+
private get descriptionResource(): URI {
124+
return !!this.getCustomLabel() ? this._preferredResource : dirname(this._preferredResource);
125+
}
126+
119127
private _shortDescription: string | undefined = undefined;
120128
private get shortDescription(): string {
121129
if (typeof this._shortDescription !== 'string') {
122-
this._shortDescription = this.labelService.getUriBasenameLabel(dirname(this._preferredResource));
130+
this._shortDescription = this.labelService.getUriBasenameLabel(this.descriptionResource);
123131
}
124132

125133
return this._shortDescription;
@@ -128,7 +136,7 @@ export abstract class AbstractResourceEditorInput extends EditorInput implements
128136
private _mediumDescription: string | undefined = undefined;
129137
private get mediumDescription(): string {
130138
if (typeof this._mediumDescription !== 'string') {
131-
this._mediumDescription = this.labelService.getUriLabel(dirname(this._preferredResource), { relative: true });
139+
this._mediumDescription = this.labelService.getUriLabel(this.descriptionResource, { relative: true });
132140
}
133141

134142
return this._mediumDescription;
@@ -137,7 +145,7 @@ export abstract class AbstractResourceEditorInput extends EditorInput implements
137145
private _longDescription: string | undefined = undefined;
138146
private get longDescription(): string {
139147
if (typeof this._longDescription !== 'string') {
140-
this._longDescription = this.labelService.getUriLabel(dirname(this._preferredResource));
148+
this._longDescription = this.labelService.getUriLabel(this.descriptionResource);
141149
}
142150

143151
return this._longDescription;

src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
170170
return capabilities;
171171
}
172172

173+
private getCustomLabel(): string | undefined {
174+
return this.customEditorLabelService.getName(this.resource);
175+
}
176+
173177
private _editorName: string | undefined = undefined;
174178
override getName(): string {
175179
if (typeof this._editorName !== 'string') {
@@ -191,10 +195,14 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
191195
}
192196
}
193197

198+
private get descriptionResource(): URI {
199+
return !!this.getCustomLabel() ? this.resource : dirname(this.resource);
200+
}
201+
194202
private _shortDescription: string | undefined = undefined;
195203
private get shortDescription(): string {
196204
if (typeof this._shortDescription !== 'string') {
197-
this._shortDescription = this.labelService.getUriBasenameLabel(dirname(this.resource));
205+
this._shortDescription = this.labelService.getUriBasenameLabel(this.descriptionResource);
198206
}
199207

200208
return this._shortDescription;
@@ -203,7 +211,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
203211
private _mediumDescription: string | undefined = undefined;
204212
private get mediumDescription(): string {
205213
if (typeof this._mediumDescription !== 'string') {
206-
this._mediumDescription = this.labelService.getUriLabel(dirname(this.resource), { relative: true });
214+
this._mediumDescription = this.labelService.getUriLabel(this.descriptionResource, { relative: true });
207215
}
208216

209217
return this._mediumDescription;
@@ -212,7 +220,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
212220
private _longDescription: string | undefined = undefined;
213221
private get longDescription(): string {
214222
if (typeof this._longDescription !== 'string') {
215-
this._longDescription = this.labelService.getUriLabel(dirname(this.resource));
223+
this._longDescription = this.labelService.getUriLabel(this.descriptionResource);
216224
}
217225

218226
return this._longDescription;

0 commit comments

Comments
 (0)