-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix view welcome empty condition #9047
Conversation
Tree view is considered empty when there are no children for the root node. Before there was a race condition as any empty fetch children response for any node marked the view as empty. Signed-off-by: Amiram Wingarten <amiram.wingarten@sap.com>
@@ -128,7 +128,7 @@ export class PluginTree extends TreeImpl { | |||
try { | |||
const children = await proxy.$getChildren(this.identifier.id, parent.id); | |||
const oldEmpty = this._isEmpty; | |||
this._isEmpty = !children || children.length === 0; | |||
this._isEmpty = !parent.id && (!children || children.length === 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify why the !parent.id
check is necessary, I do not see the same logic present in vscode:
const oldEmpty = this._isEmpty;
this._isEmpty = children.length === 0;
if (oldEmpty !== this._isEmpty) {
this._onDidChangeEmpty.fire();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vince-fugnitto this is the way i check that it is the root node.
In the vscode reference you shared the same condition exists with instanceof
:
https://github.com/microsoft/vscode/blob/7ecf23a2a2ca4905ca7c104de595632c8971d36a/src/vs/workbench/browser/parts/views/treeView.ts#L270
As far as I can tell from debugging / source code, in theia all tree nodes are interface objects and not classes that we can do instanceof
on. Is there more elegant way to identify root node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amiramw I'm fine with your explanation thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amiramw thank you for the pull-request, I've confirmed the bug on master, and how the pull-request fixes the issue using the plugin you provided 👍
Tree view is considered empty when there are no children for the root node.
Before there was a race condition as any empty fetch children response for any node marked the view as empty.
Signed-off-by: Amiram Wingarten amiram.wingarten@sap.com
What it does
Fix the condition for marking tree view as empty (which affect whether view welcome is shown).
How to test
vscode-wing-run-config-5.4.1.zip
Expected behavior: Welcome view button disappears and the tree is shown, even when clicking on tree nodes the tree still shows.
Before this PR the tree appears and immediately replaced by the welcome view as a result of fetching empty children for the created tree node.
Review checklist
Reminder for reviewers