Skip to content
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

Merged
merged 1 commit into from
Feb 16, 2021
Merged

fix view welcome empty condition #9047

merged 1 commit into from
Feb 16, 2021

Conversation

amiramw
Copy link
Member

@amiramw amiramw commented Feb 9, 2021

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

  1. Deploy vscode extension
    vscode-wing-run-config-5.4.1.zip
  2. Open run configuration view
  3. Execute there "Create Configuration"
  4. Choose defaults

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

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);
Copy link
Member

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();
}

Copy link
Member Author

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?

Copy link
Member

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!

@vince-fugnitto vince-fugnitto added tree issues related to the tree (ex: tree widget) vscode issues related to VSCode compatibility labels Feb 10, 2021
Copy link
Member

@vince-fugnitto vince-fugnitto left a 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 👍

@amiramw amiramw merged commit 945a4ca into master Feb 16, 2021
@amiramw amiramw deleted the welcome branch February 16, 2021 15:59
@github-actions github-actions bot added this to the 1.11.0 milestone Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tree issues related to the tree (ex: tree widget) vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants