-
Notifications
You must be signed in to change notification settings - Fork 28.8k
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
TreeView reveal creates a race condition with TreeDataProvider#getChildren
#192055
Comments
Pinging @alexr00 so it does not get lost 🙏 |
@EhabY the way for you to solve this from your end would be to keep track of if your tree is currently refreshing and then wait to do the reveal until after the refreshing has finished. |
@alexr00 How is it possible to track if the tree is refreshing? IIRC the refresh events do not return a promise so I would need to keep track of all visible nodes and then make sure that all of those open nodes have been reloaded (making sure to handle deleted nodes). Is there a better approach for this? But even then, this would reduce the possibility of it happening instead of eliminating it which requires internal syncing. |
I was thinking you could track if you have an unfinished |
Ah, I actually tried that but it didn't work because refreshing would call
So while we can easily check if a |
I think this is still possible. You just need to increment a counter when |
I just attempted a solution as you described and it still fails, I have added a counter that is incremented first thing in "Before" is printed first thing in
Notice how when I execute the command above, it refreshed the top level first (and finishes execution) before refreshing the rest of the tree - thus depending on the counter won't work as it finishes a refresh of the root before refreshing the rest. |
If the tree provider is loading the tree and
TreeView#reveal
is revealing an element that is not loaded yet (so the parents are loaded) then a race condition can cause the view to break with the message "Element with id X is already registered".I have also tried to create a promise queue as suggested in this comment but the issue still exists. I think this issue is caused by
reveal
andrefresh
of the tree, like it's not reveal statements causing it but rather the tree is not synchronized with reveal.See the following example repo (based on the tree view sample): https://github.com/EhabY/TreeViewRevealExample/tree/main
Test View: Reveal
2023-09-04.17-54-20.mp4
For reference this what the executed command does:
The text was updated successfully, but these errors were encountered: