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

[CLOSED] Create files on collapsed folders (#2085) #2113

Open
core-ai-bot opened this issue Aug 29, 2021 · 1 comment
Open

[CLOSED] Create files on collapsed folders (#2085) #2113

core-ai-bot opened this issue Aug 29, 2021 · 1 comment

Comments

@core-ai-bot
Copy link
Member

Issue by jbalsas
Friday Nov 23, 2012 at 00:46 GMT
Originally opened as adobe/brackets#2198


This is a possible fix for #2085 by waiting on the open_node.jstree event before trying to create a new node.

It looks like we're hitting a strange race condition in jsquery.jstree.js which appears when the node we want to open hasn't been loaded yet.

In that case, open_node triggers a load_node in line 640.

632  open_node  : function (obj, callback, skip_animation) {
         [...]
638      if(!this._is_loaded(obj)) {
639          obj.children("a").addClass("jstree-loading");
640          this.load_node(obj, function () { t.open_node(obj, callback, skip_animation); }, callback);
641      }

Almost at the same time, a different load_node is triggered from the CRRM create through create_node in line 734

726  create_node    : function (obj, position, js, callback, is_loaded) {
         [...]
733      if(obj !== -1 && !obj.length) { return false; }
734      if(!is_loaded && !this._is_loaded(obj)) { this.load_node(obj, function () { this.create_node(obj, position, js, callback, true); }); return false; }
735
736      this.__rollback();

Not digging much further, if the second load_node gets called because the first one is not completed, then create_node is not called again as expected and nothing gets created. This can be tested by adding a breakpoint in line 733. Doing that, the first load_node always finishes and the function completes ok.

By waiting to the open_node event, we're making sure we always step into create_node once the node is already loaded.

UPDATE Just to confirm, the load_node_json call just returns without doing nothing if the node is already being loaded, which causes the callback to create_node to get dropped without ever being called. Also, this check seems to have been removed in the v1.0 branch (https://github.com/vakata/jstree/blob/v.1.0/src/jstree.json.js)


jbalsas included the following code: https://github.com/adobe/brackets/pull/2198/commits

@core-ai-bot
Copy link
Member Author

Comment by gruehle
Wednesday Dec 05, 2012 at 00:28 GMT


Works great! Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant