This commit is contained in:
João Moreno 2021-05-31 11:49:03 +02:00
parent 427f48b8d1
commit edf85f1711
No known key found for this signature in database
GPG key ID: 896B853774D1A575

View file

@ -660,9 +660,15 @@ export class MouseController<T> implements IDisposable {
private changeSelection(e: IListMouseEvent<T> | IListTouchEvent<T>): void {
const focus = e.index!;
const anchor = this.list.getAnchor();
let anchor = this.list.getAnchor();
if (this.isSelectionRangeChangeEvent(e)) {
if (typeof anchor === 'undefined') {
const currentFocus = this.list.getFocus()[0];
anchor = currentFocus ?? focus;
this.list.setAnchor(anchor);
}
if (this.isSelectionRangeChangeEvent(e) && typeof anchor === 'number') {
const min = Math.min(anchor, focus);
const max = Math.max(anchor, focus);
const rangeSelection = range(min, max + 1);