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

Commit

Permalink
Merge pull request #6382 from adobe/jasonsanjose/file-watchers
Browse files Browse the repository at this point in the history
maintain selection in refreshFileTree
  • Loading branch information
iwehrman committed Jan 6, 2014
2 parents e1a3614 + 1d608b2 commit 8de072b
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1149,26 +1149,38 @@ 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");
} else {
selectedEntry = getSelectedItem();
}
_lastSelected = null;

return _loadProject(getProjectRoot().fullPath, true)
.done(function () {
_loadProject(getProjectRoot().fullPath, true)
.then(function () {
if (selectedEntry) {
_findTreeNode(selectedEntry).done(function ($node) {
_forceSelection(null, $node);
});
// 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 8de072b

Please sign in to comment.