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

Fix bug / unit test failure when closing last file in working set #2300

Merged
merged 1 commit into from
Dec 6, 2012
Merged
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
9 changes: 7 additions & 2 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ define(function (require, exports, module) {


/**
* Get the next or previous file in the working set, in MRU order (relative to currentDocument).
* Get the next or previous file in the working set, in MRU order (relative to currentDocument). May
* return currentDocument itself if working set is length 1.
* @param {Number} inc -1 for previous, +1 for next; no other values allowed
* @return {?FileEntry} null if working set empty
*/
Expand Down Expand Up @@ -489,8 +490,12 @@ define(function (require, exports, module) {
// If this was the current document shown in the editor UI, we're going to switch to a
// different document (or none if working set has no other options)
if (_currentDocument && _currentDocument.file.fullPath === file.fullPath) {
// Get the previows doc from the MRU order
// Get next most recent doc in the MRU order
var nextFile = getNextPrevFile(1);
if (nextFile && nextFile.fullPath === _currentDocument.file.fullPath) {
// getNextPrevFile() might return the file we're about to close if it's the only one open (due to wraparound)
nextFile = null;
}

// Switch editor to next document (or blank it out)
if (nextFile) {
Expand Down