Expose the focused element and change event in the TreeView API#184268
Conversation
alexr00
left a comment
There was a problem hiding this comment.
This is looking good! I will bring it to our API discussion next week and then merge it assuming that there are no concerns.
alexr00
left a comment
There was a problem hiding this comment.
@EhabY thank you for the ping. One output from API discussion that needs to be addressed is making sure that the selection is already updated with the active event fires and the active item is already updated with the selection event fires. For example, if you create a tree view and do the following:
view.onDidChangeActiveItem(e => {
console.log('selection');
console.log(view.selection);
console.log('active');
console.log(view.activeItem);
});
view.onDidChangeSelection(e => {
console.log('selection');
console.log(view.selection);
console.log('active');
console.log(view.activeItem);
});
The console logs from the two event listners should print the same thing each time they both fire. To that end $setSelection and $setFocus should be merged into one $setSelectionAndFocus so that both values are set in the same RPC call.
| this._register(this.tree.onDidChangeSelection(e => this._onDidChangeSelection.fire(e.elements))); | ||
|
|
||
| this._register(this.tree.onDidChangeSelection(e => { | ||
| if (e.elements !== this.lastSelection) { |
There was a problem hiding this comment.
It seems abstractTree.ts already filters along with extHostTreeView.ts
Is this really needed? Especially that those arrays are compared by reference
|
@alexr00 Please take another look so this can be merged 🙏 |
alexr00
left a comment
There was a problem hiding this comment.
Looks good, I've resolved the conflicts!
PR for #170248
This just exposes the focused element through
TreeView.focus. On thing that might be confusing is that theTreeView.focusmight seem like a boolean that returns true if the view is focused and not the element that is focused. DoesTreeView.focusedItemorTreeView.focusedElementmake more sense?