Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Always resolve refreshFileTree when _loadProject succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonsanjose committed Jan 6, 2014
1 parent 52f8ed3 commit 1d608b2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1149,13 +1149,15 @@ define(function (require, exports, module) {
}

/**
* Reloads the project's file tree
* Reloads the project's file tree, maintaining the current selection.
* @return {$.Promise} A promise object that will be resolved when the
* project tree is reloaded, or rejected if the project path
* fails to reload.
* fails to reload. If the previous selected entry is not found,
* the promise is still resolved.
*/
function refreshFileTree() {
var selectedEntry;
var selectedEntry,
deferred = new $.Deferred();

if (_lastSelected) {
selectedEntry = _lastSelected.data("entry");
Expand All @@ -1164,15 +1166,21 @@ define(function (require, exports, module) {
}
_lastSelected = null;

return _loadProject(getProjectRoot().fullPath, true)
_loadProject(getProjectRoot().fullPath, true)
.then(function () {
if (selectedEntry) {
return _findTreeNode(selectedEntry)
// restore selection, always resolve
_findTreeNode(selectedEntry)
.done(function ($node) {
_forceSelection(null, $node);
});
})
.always(deferred.resolve);
} else {
deferred.resolve();
}
});
}, deferred.reject);

return deferred.promise();
}

/**
Expand Down

0 comments on commit 1d608b2

Please sign in to comment.