Skip to content

Async data tree doesn't maintain consistency on focus and selection events.  #185563

@alexr00

Description

@alexr00

Given the following two event listeners on a WorkbenchAsyncDataTree:

		this._register(this.tree.onDidChangeSelection(e => {
			if (e.elements !== this.lastSelection) {
				this.lastSelection = e.elements;
				this.lastActive = this.tree?.getFocus()[0] ?? this.lastActive;
				this._onDidChangeSelectionAndFocus.fire({ selection: this.lastSelection, focus: this.lastActive });
			}
		}));
		this._register(this.tree.onDidChangeFocus(e => {
			if (e.elements.length && (e.elements[0] !== this.lastActive)) {
				this.lastActive = e.elements[0];
				this.lastSelection = this.tree?.getSelection() ?? this.lastSelection;
				this._onDidChangeSelectionAndFocus.fire({ selection: this.lastSelection, focus: this.lastActive });
			}
		}));

I would expect that when the onDidChangeSelection event fires, that the value of getFocus has already been updated.
I would also expect that when the onDidChangeFocus event fires, that the value of getSelection() has already been updated.

This came out of the API discussion for #184268.

Metadata

Metadata

Assignees

Labels

under-discussionIssue is under discussion for relevance, priority, approach

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions