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

Remove unnecessary project tree refresh after save as #6507

Merged
merged 2 commits into from
Jan 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,22 +721,17 @@ define(function (require, exports, module) {
// ignoring warnings about the contents being modified outside of
// the editor.
FileUtils.writeText(newFile, doc.getText(), true).done(function () {
// Add new file to project tree
ProjectManager.refreshFileTree().done(function () {
// If there were unsaved changes before Save As, they don't stay with the old
// file anymore - so must revert the old doc to match disk content.
// Only do this if the doc was dirty: doRevert on a file that is not dirty and
// not in the working set has the side effect of adding it to the working set.
if (doc.isDirty && !(doc.isUntitled())) {
// if the file is dirty it must be in the working set
// doRevert is side effect free in this case
doRevert(doc).always(openNewFile);
} else {
openNewFile();
}
}).fail(function (error) {
result.reject(error);
});
// If there were unsaved changes before Save As, they don't stay with the old
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have validated that the refreshFileTree call is not necessary any more since FileWatchers have landed

// file anymore - so must revert the old doc to match disk content.
// Only do this if the doc was dirty: doRevert on a file that is not dirty and
// not in the working set has the side effect of adding it to the working set.
if (doc.isDirty && !(doc.isUntitled())) {
// if the file is dirty it must be in the working set
// doRevert is side effect free in this case
doRevert(doc).always(openNewFile);
} else {
openNewFile();
}
}).fail(function (error) {
_showSaveFileError(error, path)
.done(function () {
Expand Down
2 changes: 0 additions & 2 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,6 @@ define(function (require, exports, module) {

if (_lastSelected) {
selectedEntry = _lastSelected.data("entry");
} else {
selectedEntry = getSelectedItem();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is code that has erroneously ben added by #6382?

I have validated that the file selection in various configurations works as expected when refreshing the file tree, i.e. with or with out selection in Working set or project tree. No bugs found.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly.

_lastSelected = null;

Expand Down