Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/browser/labels.ts
3294 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { localize } from '../../nls.js';
7
import { URI } from '../../base/common/uri.js';
8
import { dirname, isEqual, basenameOrAuthority } from '../../base/common/resources.js';
9
import { IconLabel, IIconLabelValueOptions, IIconLabelCreationOptions } from '../../base/browser/ui/iconLabel/iconLabel.js';
10
import { ILanguageService } from '../../editor/common/languages/language.js';
11
import { IWorkspaceContextService } from '../../platform/workspace/common/workspace.js';
12
import { IConfigurationService } from '../../platform/configuration/common/configuration.js';
13
import { IModelService } from '../../editor/common/services/model.js';
14
import { ITextFileService } from '../services/textfile/common/textfiles.js';
15
import { IDecoration, IDecorationsService, IResourceDecorationChangeEvent } from '../services/decorations/common/decorations.js';
16
import { Schemas } from '../../base/common/network.js';
17
import { FileKind, FILES_ASSOCIATIONS_CONFIG } from '../../platform/files/common/files.js';
18
import { ITextModel } from '../../editor/common/model.js';
19
import { IThemeService } from '../../platform/theme/common/themeService.js';
20
import { Event, Emitter } from '../../base/common/event.js';
21
import { ILabelService } from '../../platform/label/common/label.js';
22
import { getIconClasses } from '../../editor/common/services/getIconClasses.js';
23
import { Disposable, dispose, IDisposable, MutableDisposable } from '../../base/common/lifecycle.js';
24
import { IInstantiationService } from '../../platform/instantiation/common/instantiation.js';
25
import { normalizeDriveLetter } from '../../base/common/labels.js';
26
import { IRange } from '../../editor/common/core/range.js';
27
import { ThemeIcon } from '../../base/common/themables.js';
28
import { INotebookDocumentService, extractCellOutputDetails } from '../services/notebook/common/notebookDocumentService.js';
29
30
export interface IResourceLabelProps {
31
resource?: URI | { primary?: URI; secondary?: URI };
32
name?: string | string[];
33
range?: IRange;
34
description?: string;
35
}
36
37
function toResource(props: IResourceLabelProps | undefined): URI | undefined {
38
if (!props || !props.resource) {
39
return undefined;
40
}
41
42
if (URI.isUri(props.resource)) {
43
return props.resource;
44
}
45
46
return props.resource.primary;
47
}
48
49
export interface IResourceLabelOptions extends IIconLabelValueOptions {
50
51
/**
52
* A hint to the file kind of the resource.
53
*/
54
fileKind?: FileKind;
55
56
/**
57
* File decorations to use for the label.
58
*/
59
readonly fileDecorations?: { colors: boolean; badges: boolean };
60
61
/**
62
* Will take the provided label as is and e.g. not override it for untitled files.
63
*/
64
readonly forceLabel?: boolean;
65
66
/**
67
* A prefix to be added to the name of the label.
68
*/
69
readonly namePrefix?: string;
70
71
/**
72
* Uses the provided icon instead of deriving a resource icon.
73
*/
74
readonly icon?: ThemeIcon | URI;
75
}
76
77
export interface IFileLabelOptions extends IResourceLabelOptions {
78
hideLabel?: boolean;
79
hidePath?: boolean;
80
range?: IRange;
81
}
82
83
export interface IResourceLabel extends IDisposable {
84
85
readonly element: HTMLElement;
86
87
readonly onDidRender: Event<void>;
88
89
/**
90
* Most generic way to apply a label with raw information.
91
*/
92
setLabel(label?: string, description?: string, options?: IIconLabelValueOptions): void;
93
94
/**
95
* Convenient method to apply a label by passing a resource along.
96
*
97
* Note: for file resources consider to use the #setFile() method instead.
98
*/
99
setResource(label: IResourceLabelProps, options?: IResourceLabelOptions): void;
100
101
/**
102
* Convenient method to render a file label based on a resource.
103
*/
104
setFile(resource: URI, options?: IFileLabelOptions): void;
105
106
/**
107
* Resets the label to be empty.
108
*/
109
clear(): void;
110
}
111
112
export interface IResourceLabelsContainer {
113
readonly onDidChangeVisibility: Event<boolean>;
114
}
115
116
export const DEFAULT_LABELS_CONTAINER: IResourceLabelsContainer = {
117
onDidChangeVisibility: Event.None
118
};
119
120
export class ResourceLabels extends Disposable {
121
122
private readonly _onDidChangeDecorations = this._register(new Emitter<void>());
123
get onDidChangeDecorations() { return this._onDidChangeDecorations.event; }
124
125
private widgets: ResourceLabelWidget[] = [];
126
private labels: IResourceLabel[] = [];
127
128
constructor(
129
container: IResourceLabelsContainer,
130
@IInstantiationService private readonly instantiationService: IInstantiationService,
131
@IConfigurationService private readonly configurationService: IConfigurationService,
132
@IModelService private readonly modelService: IModelService,
133
@IWorkspaceContextService private readonly workspaceService: IWorkspaceContextService,
134
@ILanguageService private readonly languageService: ILanguageService,
135
@IDecorationsService private readonly decorationsService: IDecorationsService,
136
@IThemeService private readonly themeService: IThemeService,
137
@ILabelService private readonly labelService: ILabelService,
138
@ITextFileService private readonly textFileService: ITextFileService
139
) {
140
super();
141
142
this.registerListeners(container);
143
}
144
145
private registerListeners(container: IResourceLabelsContainer): void {
146
147
// notify when visibility changes
148
this._register(container.onDidChangeVisibility(visible => {
149
this.widgets.forEach(widget => widget.notifyVisibilityChanged(visible));
150
}));
151
152
// notify when extensions are registered with potentially new languages
153
this._register(this.languageService.onDidChange(() => this.widgets.forEach(widget => widget.notifyExtensionsRegistered())));
154
155
// notify when model language changes
156
this._register(this.modelService.onModelLanguageChanged(e => {
157
if (!e.model.uri) {
158
return; // we need the resource to compare
159
}
160
161
this.widgets.forEach(widget => widget.notifyModelLanguageChanged(e.model));
162
}));
163
164
// notify when model is added
165
this._register(this.modelService.onModelAdded(model => {
166
if (!model.uri) {
167
return; // we need the resource to compare
168
}
169
170
this.widgets.forEach(widget => widget.notifyModelAdded(model));
171
}));
172
173
// notify when workspace folders changes
174
this._register(this.workspaceService.onDidChangeWorkspaceFolders(() => {
175
this.widgets.forEach(widget => widget.notifyWorkspaceFoldersChange());
176
}));
177
178
// notify when file decoration changes
179
this._register(this.decorationsService.onDidChangeDecorations(e => {
180
let notifyDidChangeDecorations = false;
181
this.widgets.forEach(widget => {
182
if (widget.notifyFileDecorationsChanges(e)) {
183
notifyDidChangeDecorations = true;
184
}
185
});
186
187
if (notifyDidChangeDecorations) {
188
this._onDidChangeDecorations.fire();
189
}
190
}));
191
192
// notify when theme changes
193
this._register(this.themeService.onDidColorThemeChange(() => this.widgets.forEach(widget => widget.notifyThemeChange())));
194
195
// notify when files.associations changes
196
this._register(this.configurationService.onDidChangeConfiguration(e => {
197
if (e.affectsConfiguration(FILES_ASSOCIATIONS_CONFIG)) {
198
this.widgets.forEach(widget => widget.notifyFileAssociationsChange());
199
}
200
}));
201
202
// notify when label formatters change
203
this._register(this.labelService.onDidChangeFormatters(e => {
204
this.widgets.forEach(widget => widget.notifyFormattersChange(e.scheme));
205
}));
206
207
// notify when untitled labels change
208
this._register(this.textFileService.untitled.onDidChangeLabel(model => {
209
this.widgets.forEach(widget => widget.notifyUntitledLabelChange(model.resource));
210
}));
211
}
212
213
get(index: number): IResourceLabel {
214
return this.labels[index];
215
}
216
217
create(container: HTMLElement, options?: IIconLabelCreationOptions): IResourceLabel {
218
const widget = this.instantiationService.createInstance(ResourceLabelWidget, container, options);
219
220
// Only expose a handle to the outside
221
const label: IResourceLabel = {
222
element: widget.element,
223
get onDidRender() { return widget.onDidRender; },
224
setLabel: (label: string, description?: string, options?: IIconLabelValueOptions) => widget.setLabel(label, description, options),
225
setResource: (label: IResourceLabelProps, options?: IResourceLabelOptions) => widget.setResource(label, options),
226
setFile: (resource: URI, options?: IFileLabelOptions) => widget.setFile(resource, options),
227
clear: () => widget.clear(),
228
dispose: () => this.disposeWidget(widget)
229
};
230
231
// Store
232
this.labels.push(label);
233
this.widgets.push(widget);
234
235
return label;
236
}
237
238
private disposeWidget(widget: ResourceLabelWidget): void {
239
const index = this.widgets.indexOf(widget);
240
if (index > -1) {
241
this.widgets.splice(index, 1);
242
this.labels.splice(index, 1);
243
}
244
245
dispose(widget);
246
}
247
248
clear(): void {
249
this.widgets = dispose(this.widgets);
250
this.labels = [];
251
}
252
253
override dispose(): void {
254
super.dispose();
255
256
this.clear();
257
}
258
}
259
260
/**
261
* Note: please consider to use `ResourceLabels` if you are in need
262
* of more than one label for your widget.
263
*/
264
export class ResourceLabel extends ResourceLabels {
265
266
private label: IResourceLabel;
267
get element(): IResourceLabel { return this.label; }
268
269
constructor(
270
container: HTMLElement,
271
options: IIconLabelCreationOptions | undefined,
272
@IInstantiationService instantiationService: IInstantiationService,
273
@IConfigurationService configurationService: IConfigurationService,
274
@IModelService modelService: IModelService,
275
@IWorkspaceContextService workspaceService: IWorkspaceContextService,
276
@ILanguageService languageService: ILanguageService,
277
@IDecorationsService decorationsService: IDecorationsService,
278
@IThemeService themeService: IThemeService,
279
@ILabelService labelService: ILabelService,
280
@ITextFileService textFileService: ITextFileService
281
) {
282
super(DEFAULT_LABELS_CONTAINER, instantiationService, configurationService, modelService, workspaceService, languageService, decorationsService, themeService, labelService, textFileService);
283
284
this.label = this._register(this.create(container, options));
285
}
286
}
287
288
enum Redraw {
289
Basic = 1,
290
Full = 2
291
}
292
293
class ResourceLabelWidget extends IconLabel {
294
295
private readonly _onDidRender = this._register(new Emitter<void>());
296
get onDidRender() { return this._onDidRender.event; }
297
298
private label: IResourceLabelProps | undefined = undefined;
299
private readonly decoration = this._register(new MutableDisposable<IDecoration>());
300
private options: IResourceLabelOptions | undefined = undefined;
301
302
private computedIconClasses: string[] | undefined = undefined;
303
private computedLanguageId: string | undefined = undefined;
304
private computedPathLabel: string | undefined = undefined;
305
private computedWorkspaceFolderLabel: string | undefined = undefined;
306
307
private needsRedraw: Redraw | undefined = undefined;
308
private isHidden: boolean = false;
309
310
constructor(
311
container: HTMLElement,
312
options: IIconLabelCreationOptions | undefined,
313
@ILanguageService private readonly languageService: ILanguageService,
314
@IModelService private readonly modelService: IModelService,
315
@IDecorationsService private readonly decorationsService: IDecorationsService,
316
@ILabelService private readonly labelService: ILabelService,
317
@ITextFileService private readonly textFileService: ITextFileService,
318
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
319
@INotebookDocumentService private readonly notebookDocumentService: INotebookDocumentService
320
) {
321
super(container, options);
322
}
323
324
notifyVisibilityChanged(visible: boolean): void {
325
if (visible === this.isHidden) {
326
this.isHidden = !visible;
327
328
if (visible && this.needsRedraw) {
329
this.render({
330
updateIcon: this.needsRedraw === Redraw.Full,
331
updateDecoration: this.needsRedraw === Redraw.Full
332
});
333
334
this.needsRedraw = undefined;
335
}
336
}
337
}
338
339
notifyModelLanguageChanged(model: ITextModel): void {
340
this.handleModelEvent(model);
341
}
342
343
notifyModelAdded(model: ITextModel): void {
344
this.handleModelEvent(model);
345
}
346
347
private handleModelEvent(model: ITextModel): void {
348
const resource = toResource(this.label);
349
if (!resource) {
350
return; // only update if resource exists
351
}
352
353
if (isEqual(model.uri, resource)) {
354
if (this.computedLanguageId !== model.getLanguageId()) {
355
this.computedLanguageId = model.getLanguageId();
356
this.render({ updateIcon: true, updateDecoration: false }); // update if the language id of the model has changed from our last known state
357
}
358
}
359
}
360
361
notifyFileDecorationsChanges(e: IResourceDecorationChangeEvent): boolean {
362
if (!this.options) {
363
return false;
364
}
365
366
const resource = toResource(this.label);
367
if (!resource) {
368
return false;
369
}
370
371
if (this.options.fileDecorations && e.affectsResource(resource)) {
372
return this.render({ updateIcon: false, updateDecoration: true });
373
}
374
375
return false;
376
}
377
378
notifyExtensionsRegistered(): void {
379
this.render({ updateIcon: true, updateDecoration: false });
380
}
381
382
notifyThemeChange(): void {
383
this.render({ updateIcon: false, updateDecoration: false });
384
}
385
386
notifyFileAssociationsChange(): void {
387
this.render({ updateIcon: true, updateDecoration: false });
388
}
389
390
notifyFormattersChange(scheme: string): void {
391
if (toResource(this.label)?.scheme === scheme) {
392
this.render({ updateIcon: false, updateDecoration: false });
393
}
394
}
395
396
notifyUntitledLabelChange(resource: URI): void {
397
if (isEqual(resource, toResource(this.label))) {
398
this.render({ updateIcon: false, updateDecoration: false });
399
}
400
}
401
402
notifyWorkspaceFoldersChange(): void {
403
if (typeof this.computedWorkspaceFolderLabel === 'string') {
404
const resource = toResource(this.label);
405
if (URI.isUri(resource) && this.label?.name === this.computedWorkspaceFolderLabel) {
406
this.setFile(resource, this.options);
407
}
408
}
409
}
410
411
setFile(resource: URI, options?: IFileLabelOptions): void {
412
const hideLabel = options?.hideLabel;
413
let name: string | undefined;
414
if (!hideLabel) {
415
if (options?.fileKind === FileKind.ROOT_FOLDER) {
416
const workspaceFolder = this.contextService.getWorkspaceFolder(resource);
417
if (workspaceFolder) {
418
name = workspaceFolder.name;
419
this.computedWorkspaceFolderLabel = name;
420
}
421
}
422
423
if (!name) {
424
name = normalizeDriveLetter(basenameOrAuthority(resource));
425
}
426
}
427
428
let description: string | undefined;
429
if (!options?.hidePath) {
430
const descriptionCandidate = this.labelService.getUriLabel(dirname(resource), { relative: true });
431
if (descriptionCandidate && descriptionCandidate !== '.') {
432
// omit description if its not significant: a relative path
433
// of '.' just indicates that there is no parent to the path
434
// https://github.com/microsoft/vscode/issues/208692
435
description = descriptionCandidate;
436
}
437
}
438
439
this.setResource({ resource, name, description, range: options?.range }, options);
440
}
441
442
setResource(label: IResourceLabelProps, options: IResourceLabelOptions = Object.create(null)): void {
443
const resource = toResource(label);
444
const isSideBySideEditor = label?.resource && !URI.isUri(label.resource);
445
446
if (!options.forceLabel && !isSideBySideEditor && resource?.scheme === Schemas.untitled) {
447
// Untitled labels are very dynamic because they may change
448
// whenever the content changes (unless a path is associated).
449
// As such we always ask the actual editor for it's name and
450
// description to get latest in case name/description are
451
// provided. If they are not provided from the label we got
452
// we assume that the client does not want to display them
453
// and as such do not override.
454
//
455
// We do not touch the label if it represents a primary-secondary
456
// because in that case we expect it to carry a proper label
457
// and description.
458
const untitledModel = this.textFileService.untitled.get(resource);
459
if (untitledModel && !untitledModel.hasAssociatedFilePath) {
460
if (typeof label.name === 'string') {
461
label.name = untitledModel.name;
462
}
463
464
if (typeof label.description === 'string') {
465
const untitledDescription = untitledModel.resource.path;
466
if (label.name !== untitledDescription) {
467
label.description = untitledDescription;
468
} else {
469
label.description = undefined;
470
}
471
}
472
473
const untitledTitle = untitledModel.resource.path;
474
if (untitledModel.name !== untitledTitle) {
475
options.title = `${untitledModel.name} • ${untitledTitle}`;
476
} else {
477
options.title = untitledTitle;
478
}
479
}
480
}
481
482
if (!options.forceLabel && !isSideBySideEditor && resource?.scheme === Schemas.vscodeNotebookCell) {
483
// Notebook cells are embeded in a notebook document
484
// As such we always ask the actual notebook document
485
// for its position in the document.
486
const notebookDocument = this.notebookDocumentService.getNotebook(resource);
487
const cellIndex = notebookDocument?.getCellIndex(resource);
488
if (notebookDocument && cellIndex !== undefined && typeof label.name === 'string') {
489
options.title = localize('notebookCellLabel', "{0} • Cell {1}", label.name, `${cellIndex + 1}`);
490
}
491
492
if (typeof label.name === 'string' && notebookDocument && cellIndex !== undefined && typeof label.name === 'string') {
493
label.name = localize('notebookCellLabel', "{0} • Cell {1}", label.name, `${cellIndex + 1}`);
494
}
495
}
496
497
if (!options.forceLabel && !isSideBySideEditor && resource?.scheme === Schemas.vscodeNotebookCellOutput) {
498
const notebookDocument = this.notebookDocumentService.getNotebook(resource);
499
const outputUriData = extractCellOutputDetails(resource);
500
if (outputUriData?.cellFragment) {
501
if (!outputUriData.notebook) {
502
return;
503
}
504
const cellUri = outputUriData.notebook.with({
505
scheme: Schemas.vscodeNotebookCell,
506
fragment: outputUriData.cellFragment
507
});
508
const cellIndex = notebookDocument?.getCellIndex(cellUri);
509
const outputIndex = outputUriData.outputIndex;
510
511
if (cellIndex !== undefined && outputIndex !== undefined && typeof label.name === 'string') {
512
label.name = localize(
513
'notebookCellOutputLabel',
514
"{0} • Cell {1} • Output {2}",
515
label.name,
516
`${cellIndex + 1}`,
517
`${outputIndex + 1}`
518
);
519
} else if (cellIndex !== undefined && typeof label.name === 'string') {
520
label.name = localize(
521
'notebookCellOutputLabelSimple',
522
"{0} • Cell {1} • Output",
523
label.name,
524
`${cellIndex + 1}`
525
);
526
}
527
}
528
}
529
530
if (options.namePrefix) {
531
if (typeof label.name === 'string') {
532
label.name = options.namePrefix + label.name;
533
} else if (Array.isArray(label.name) && label.name.length > 0) {
534
label.name = [options.namePrefix + label.name[0], ...label.name.slice(1)];
535
}
536
}
537
538
const hasResourceChanged = this.hasResourceChanged(label);
539
const hasPathLabelChanged = hasResourceChanged || this.hasPathLabelChanged(label);
540
const hasFileKindChanged = this.hasFileKindChanged(options);
541
const hasIconChanged = this.hasIconChanged(options);
542
543
this.label = label;
544
this.options = options;
545
546
if (hasResourceChanged) {
547
this.computedLanguageId = undefined; // reset computed language since resource changed
548
}
549
550
if (hasPathLabelChanged) {
551
this.computedPathLabel = undefined; // reset path label due to resource/path-label change
552
}
553
554
this.render({
555
updateIcon: hasResourceChanged || hasFileKindChanged || hasIconChanged,
556
updateDecoration: hasResourceChanged || hasFileKindChanged
557
});
558
}
559
560
private hasFileKindChanged(newOptions?: IResourceLabelOptions): boolean {
561
const newFileKind = newOptions?.fileKind;
562
const oldFileKind = this.options?.fileKind;
563
564
return newFileKind !== oldFileKind; // same resource but different kind (file, folder)
565
}
566
567
private hasResourceChanged(newLabel: IResourceLabelProps): boolean {
568
const newResource = toResource(newLabel);
569
const oldResource = toResource(this.label);
570
571
if (newResource && oldResource) {
572
return newResource.toString() !== oldResource.toString();
573
}
574
575
if (!newResource && !oldResource) {
576
return false;
577
}
578
579
return true;
580
}
581
582
private hasPathLabelChanged(newLabel: IResourceLabelProps): boolean {
583
const newResource = toResource(newLabel);
584
585
return !!newResource && this.computedPathLabel !== this.labelService.getUriLabel(newResource);
586
}
587
588
private hasIconChanged(newOptions?: IResourceLabelOptions): boolean {
589
return this.options?.icon !== newOptions?.icon;
590
}
591
592
clear(): void {
593
this.label = undefined;
594
this.options = undefined;
595
this.computedLanguageId = undefined;
596
this.computedIconClasses = undefined;
597
this.computedPathLabel = undefined;
598
599
this.setLabel('');
600
}
601
602
private render(options: { updateIcon: boolean; updateDecoration: boolean }): boolean {
603
if (this.isHidden) {
604
if (this.needsRedraw !== Redraw.Full) {
605
this.needsRedraw = (options.updateIcon || options.updateDecoration) ? Redraw.Full : Redraw.Basic;
606
}
607
608
return false;
609
}
610
611
if (options.updateIcon) {
612
this.computedIconClasses = undefined;
613
}
614
615
if (!this.label) {
616
return false;
617
}
618
619
const iconLabelOptions: IIconLabelValueOptions & { extraClasses: string[] } = {
620
title: '',
621
italic: this.options?.italic,
622
strikethrough: this.options?.strikethrough,
623
matches: this.options?.matches,
624
descriptionMatches: this.options?.descriptionMatches,
625
extraClasses: [],
626
separator: this.options?.separator,
627
domId: this.options?.domId,
628
disabledCommand: this.options?.disabledCommand,
629
labelEscapeNewLines: this.options?.labelEscapeNewLines,
630
descriptionTitle: this.options?.descriptionTitle,
631
};
632
633
const resource = toResource(this.label);
634
635
if (this.options?.title !== undefined) {
636
iconLabelOptions.title = this.options.title;
637
}
638
639
if (resource && resource.scheme !== Schemas.data /* do not accidentally inline Data URIs */
640
&& (
641
(!this.options?.title)
642
|| ((typeof this.options.title !== 'string') && !this.options.title.markdownNotSupportedFallback)
643
)) {
644
645
if (!this.computedPathLabel) {
646
this.computedPathLabel = this.labelService.getUriLabel(resource);
647
}
648
649
if (!iconLabelOptions.title || (typeof iconLabelOptions.title === 'string')) {
650
iconLabelOptions.title = this.computedPathLabel;
651
} else if (!iconLabelOptions.title.markdownNotSupportedFallback) {
652
iconLabelOptions.title.markdownNotSupportedFallback = this.computedPathLabel;
653
}
654
}
655
656
if (this.options && !this.options.hideIcon) {
657
if (!this.computedIconClasses) {
658
this.computedIconClasses = getIconClasses(this.modelService, this.languageService, resource, this.options.fileKind, this.options.icon);
659
}
660
661
if (URI.isUri(this.options.icon)) {
662
iconLabelOptions.iconPath = this.options.icon;
663
}
664
665
iconLabelOptions.extraClasses = this.computedIconClasses.slice(0);
666
}
667
668
if (this.options?.extraClasses) {
669
iconLabelOptions.extraClasses.push(...this.options.extraClasses);
670
}
671
672
if (this.options?.fileDecorations && resource) {
673
if (options.updateDecoration) {
674
this.decoration.value = this.decorationsService.getDecoration(resource, this.options.fileKind !== FileKind.FILE);
675
}
676
677
const decoration = this.decoration.value;
678
if (decoration) {
679
if (decoration.tooltip) {
680
if (typeof iconLabelOptions.title === 'string') {
681
iconLabelOptions.title = `${iconLabelOptions.title} • ${decoration.tooltip}`;
682
} else if (typeof iconLabelOptions.title?.markdown === 'string') {
683
const title = `${iconLabelOptions.title.markdown} • ${decoration.tooltip}`;
684
iconLabelOptions.title = { markdown: title, markdownNotSupportedFallback: title };
685
}
686
}
687
688
if (decoration.strikethrough) {
689
iconLabelOptions.strikethrough = true;
690
}
691
692
if (this.options.fileDecorations.colors) {
693
iconLabelOptions.extraClasses.push(decoration.labelClassName);
694
}
695
696
if (this.options.fileDecorations.badges) {
697
iconLabelOptions.extraClasses.push(decoration.badgeClassName);
698
iconLabelOptions.extraClasses.push(decoration.iconClassName);
699
}
700
}
701
}
702
703
if (this.label.range) {
704
iconLabelOptions.suffix = this.label.range.startLineNumber !== this.label.range.endLineNumber ?
705
`:${this.label.range.startLineNumber}-${this.label.range.endLineNumber}` :
706
`:${this.label.range.startLineNumber}`;
707
}
708
709
this.setLabel(this.label.name ?? '', this.label.description, iconLabelOptions);
710
711
this._onDidRender.fire();
712
713
return true;
714
}
715
716
override dispose(): void {
717
super.dispose();
718
719
this.label = undefined;
720
this.options = undefined;
721
this.computedLanguageId = undefined;
722
this.computedIconClasses = undefined;
723
this.computedPathLabel = undefined;
724
this.computedWorkspaceFolderLabel = undefined;
725
}
726
}
727
728