Skip to content

Commit

Permalink
Fix settings sync tree views
Browse files Browse the repository at this point in the history
Fixes #127480
  • Loading branch information
alexr00 committed Jun 29, 2021
1 parent 64a6343 commit ffe0bd1
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions src/vs/workbench/browser/parts/views/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const noDataProviderMessage = localize('no-dataprovider', "There is no data prov

class Tree extends WorkbenchAsyncDataTree<ITreeItem, ITreeItem, FuzzyScore> { }

export class TreeView extends Disposable implements ITreeView {
abstract class AbstractTreeView extends Disposable implements ITreeView {

private isVisible: boolean = false;
private _hasIconForParentNode = false;
Expand Down Expand Up @@ -432,8 +432,14 @@ export class TreeView extends Disposable implements ITreeView {
}

this._onDidChangeVisibility.fire(this.isVisible);

if (this.visible) {
this.activate();
}
}

protected abstract activate(): void;

focus(reveal: boolean = true): void {
if (this.tree && this.root.children && this.root.children.length > 0) {
// Make sure the current selected element is revealed
Expand Down Expand Up @@ -1153,7 +1159,7 @@ class TreeMenus extends Disposable implements IDisposable {
}
}

export class CustomTreeView extends TreeView {
export class CustomTreeView extends AbstractTreeView {

private activated: boolean = false;

Expand All @@ -1176,14 +1182,7 @@ export class CustomTreeView extends TreeView {
super(id, title, themeService, instantiationService, commandService, configurationService, progressService, contextMenuService, keybindingService, notificationService, viewDescriptorService, hoverService, contextKeyService);
}

override setVisibility(isVisible: boolean): void {
super.setVisibility(isVisible);
if (this.visible) {
this.activate();
}
}

private activate() {
protected activate() {
if (!this.activated) {
this.createTree();
this.progressService.withProgress({ location: this.id }, () => this.extensionService.activateByEvent(`onView:${this.id}`))
Expand All @@ -1196,6 +1195,36 @@ export class CustomTreeView extends TreeView {
}
}

export class TreeView extends AbstractTreeView {

private activated: boolean = false;

constructor(
id: string,
title: string,
@IThemeService themeService: IThemeService,
@IInstantiationService instantiationService: IInstantiationService,
@ICommandService commandService: ICommandService,
@IConfigurationService configurationService: IConfigurationService,
@IProgressService progressService: IProgressService,
@IContextMenuService contextMenuService: IContextMenuService,
@IKeybindingService keybindingService: IKeybindingService,
@INotificationService notificationService: INotificationService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@IContextKeyService contextKeyService: IContextKeyService,
@IHoverService hoverService: IHoverService,
) {
super(id, title, themeService, instantiationService, commandService, configurationService, progressService, contextMenuService, keybindingService, notificationService, viewDescriptorService, hoverService, contextKeyService);
}

protected activate() {
if (!this.activated) {
this.createTree();
this.activated = true;
}
}
}

export class CustomTreeViewDragAndDrop implements ITreeDragAndDrop<ITreeItem> {
constructor(private dndController: ITreeViewDragAndDropController, @ILabelService private readonly labelService: ILabelService) { }

Expand Down

0 comments on commit ffe0bd1

Please sign in to comment.