fix(list-selection): Properly iterate over the selected indexes when expanding selection

This commit fixes a bug in which you couldn't shift select threads from
the bottom to the top (i.e. select a thread, shift-click a thread on top of it
would not select the range of threads).

This bug was introduced by a translation from coffeescript to JS.
Specifically, by converting

```
for idx in [startIdx..endIdx]
```

to
```
for (let idx = startIdx; idx <= endIdx; idx++) { ... }
```

The coffeescript range syntax for `[x..y]` automatically generates the
correct range when x > y or when x < y, generating a descending or
ascending range respectively.
However, our transaltion simply iterated ascendingly from `startIdx`
to `endIdx`, which would be a no-op when the `startIdx` was greater than
the `endIdx`, which was the case when shift-selecting threads from bottom to top.
This commit is contained in:
Juan Tejada 2016-11-02 11:26:05 -07:00
parent 4692484094
commit 7865da6b7d

View file

@ -145,11 +145,15 @@ export default class ListSelection {
if (startIdx === -1 || endIdx === -1) {
return;
}
for (let idx = startIdx; idx <= endIdx; idx++) {
const count = Math.abs(startIdx - endIdx) + 1
const indexes = new Array(count)
.fill(0)
.map((val, idx) => (startIdx > endIdx ? startIdx - idx : startIdx + idx))
indexes.forEach((idx) => {
const idxItem = this._view.get(idx);
this._items = _.reject(this._items, t => t.id === idxItem.id);
this._items.push(idxItem);
}
})
}
this.trigger();
}