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

Issue #2076: Two indistinguishable events for different cases of working set reordering #4450

Merged
merged 3 commits into from
Jul 23, 2013
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
10 changes: 6 additions & 4 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ define(function (require, exports, module) {

/**
* Mutually exchanges the files at the indexes passed by parameters.
* @param {!number} index - old file index
* @param {!number} index - new file index
* @param {number} index Old file index
* @param {number} index New file index
*/
function swapWorkingSetIndexes(index1, index2) {
var length = _workingSet.length - 1;
Expand All @@ -378,13 +378,15 @@ define(function (require, exports, module) {
temp = _workingSet[index1];
_workingSet[index1] = _workingSet[index2];
_workingSet[index2] = temp;

$(exports).triggerHandler("workingSetSort");
$(exports).triggerHandler("workingSetDisableAutoSorting");
}
}

/**
* Sorts _workingSet using the compare function
* @param {!function(FileEntry, FileEntry)} compareFn - the function that will be used inside JavaScript's
* @param {function(FileEntry, FileEntry): number} compareFn The function that will be used inside JavaScript's
* sort function. The return a value should be >0 (sort a to a lower index than b), =0 (leaves a and b
* unchanged with respect to each other) or <0 (sort b to a lower index than a) and must always returns
* the same value when given a specific pair of elements a and b as its two arguments.
Expand Down Expand Up @@ -422,7 +424,7 @@ define(function (require, exports, module) {
/**
* 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
* @param {number} inc -1 for previous, +1 for next; no other values allowed
* @return {?FileEntry} null if working set empty
*/
function getNextPrevFile(inc) {
Expand Down
20 changes: 18 additions & 2 deletions src/project/WorkingSetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ define(function (require, exports, module) {
$openFilesContainer,
$openFilesList;

/**
* @private
* Internal flag to suppress redrawing the Working Set after a workingSetSort event.
* @type {boolean}
*/
var _suppressSortRedraw = false;


/**
* @private
* Redraw selection when list size changes or DocumentManager currentDocument changes.
Expand Down Expand Up @@ -179,6 +187,9 @@ define(function (require, exports, module) {
if (!moved && Math.abs(top) > 3) {
Menus.closeAll();
moved = true;

// Don't redraw the working set for the next events
_suppressSortRedraw = true;
}
}

Expand Down Expand Up @@ -256,6 +267,9 @@ define(function (require, exports, module) {
if (addBottomShadow) {
ViewUtils.addScrollerShadow($openFilesContainer[0], null, true);
}

// The drag is done, so set back to the default
_suppressSortRedraw = false;
}
}

Expand Down Expand Up @@ -550,11 +564,13 @@ define(function (require, exports, module) {
_redraw();
}

/**
/**
* @private
*/
function _handleWorkingSetSort() {
_rebuildWorkingSet(true);
if (!_suppressSortRedraw) {
_rebuildWorkingSet(true);
}
}

/**
Expand Down