Skip to content

Commit 95f0ea4

Browse files
Eric Amodioeamodio
authored andcommitted
Adds lazy allocation for the itle desc dom node
1 parent 8da30f9 commit 95f0ea4

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/vs/workbench/browser/parts/views/viewPaneContainer.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export abstract class ViewPane extends Pane implements IView {
341341
return this.viewDescriptorService.getViewDescriptorById(this.id)?.containerIcon || 'codicon-window';
342342
}
343343

344-
protected renderHeaderTitle(container: HTMLElement, title: string, description?: string | undefined): void {
344+
protected renderHeaderTitle(container: HTMLElement, title: string): void {
345345
this.iconContainer = append(container, $('.icon', undefined));
346346
const icon = this.getIcon();
347347

@@ -367,7 +367,10 @@ export abstract class ViewPane extends Pane implements IView {
367367

368368
const calculatedTitle = this.calculateTitle(title);
369369
this.titleContainer = append(container, $('h3.title', undefined, calculatedTitle));
370-
this.titleDescriptionContainer = append(container, $('span.description', undefined, this._titleDescription ?? ''));
370+
371+
if (this._titleDescription) {
372+
this.setTitleDescription(this._titleDescription, container);
373+
}
371374

372375
this.iconContainer.title = calculatedTitle;
373376
this.iconContainer.setAttribute('aria-label', calculatedTitle);
@@ -388,10 +391,17 @@ export abstract class ViewPane extends Pane implements IView {
388391
this._onDidChangeTitleArea.fire();
389392
}
390393

391-
protected updateTitleDescription(description?: string | undefined): void {
394+
private setTitleDescription(description: string | undefined, headerContainer: HTMLElement | undefined = this.headerContainer) {
392395
if (this.titleDescriptionContainer) {
393396
this.titleDescriptionContainer.textContent = description ?? '';
394397
}
398+
else if (description && headerContainer) {
399+
this.titleDescriptionContainer = append(headerContainer, $('span.description', undefined, description));
400+
}
401+
}
402+
403+
protected updateTitleDescription(description?: string | undefined): void {
404+
this.setTitleDescription(description);
395405

396406
this._titleDescription = description;
397407
this._onDidChangeTitleArea.fire();

0 commit comments

Comments
 (0)