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 #1564 from adobe/randy/issue-1544
Browse files Browse the repository at this point in the history
Fix bugs #1543 and #1544: working set files are not guaranteed to be openable, so check for failure; defer assertion until it's (supposed to be) guaranteed to be valid
  • Loading branch information
peterflynn committed Sep 6, 2012
2 parents c321198 + 7b1480c commit ee9f52f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,22 @@ define(function (require, exports, module) {

// Switch editor to next document (or blank it out)
if (nextFile) {
CommandManager.execute(Commands.FILE_OPEN, { fullPath: nextFile.fullPath });
CommandManager.execute(Commands.FILE_OPEN, { fullPath: nextFile.fullPath })
.done(function () {
// (Now we're guaranteed that the current document is not the one we're closing)
console.assert(!(_currentDocument && _currentDocument.file.fullPath === file.fullPath));
})
.fail(function () {
// File chosen to be switched to could not be opened, and the original file
// is still in editor. Close it again so code will try to open the next file,
// or empty the editor if there are no other files.
closeFullEditor(file);
});
} else {
_clearCurrentDocument();
}
}

// (Now we're guaranteed that the current document is not the one we're closing)
console.assert(!(_currentDocument && _currentDocument.file.fullPath === file.fullPath));

// Remove closed doc from working set, if it was in there
// This happens regardless of whether the document being closed was the current one or not
removeFromWorkingSet(file);
Expand Down

0 comments on commit ee9f52f

Please sign in to comment.