-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Prevent duplicate tree nodes when renaming the only file in a directory #6522
Conversation
…e in a directory caused duplicate tree nodes to appear
Assigning @couzteau for review |
will look at this later tonight. |
// jstree attempts to load empty nodes during the create workflow, | ||
// resulting in duplicate nodes for the same entry, see | ||
// https://github.com/adobe/brackets/issues/6474. | ||
if (wasOpen && isClosed) { |
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.
if I understand correctly the fix works because catching the case where the folder was open before and is closed now allows to avoid creating dupe nodes by calling _projectTree.jstree("open_node", $directoryNode); instead of _createNode($directoryNode in line 1987. That seems to be working fine.
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.
Yes. What would happen is that within jstree's create_node
workflow, it would see the parent folder as !is_loaded
, call our _treeDataProvider
function to populate the list of children, then continue to finish create_node
by adding the duplicate here.
Done with initial review. The fix works great. I have just one Q regarding the additional redraw, see comment above. While testing I have seen a few cases where the tree wouldn't update at all after renaming a file. In these situations I was also not hitting any breakpoints in the _fileSystemChange handler. Couldn't really repro, but I have seen it a couple of times. That would be a different issue I think, but for the time being I cannot really put my finder on it. |
The additional redraw (to fix the selection marker drawing) is necessary since the first synchronous redraw will happen when the nodes are deleted for this event. This additional async redraw happens after jstree calls into the |
As far as not hitting breakpoints in |
Thanks, I understand now. Actually it dawned on me lats night that the redraw handler and the open node call are directly related ;) - Of course they are! Thanks. This is looking good. The fix is working well and the tests are passing. Merging. |
Prevent duplicate tree nodes when renaming the only file in a directory
Use jstree open_node in corner case #6474 where renaming the only file in a directory caused duplicate tree nodes to appear