Skip to content

Commit

Permalink
Revert "Do not clear selection in single-select case (fixes microsoft…
Browse files Browse the repository at this point in the history
…#57850)"

This reverts commit a6626a8.
  • Loading branch information
aeschli committed Sep 20, 2018
1 parent 1b38a64 commit 7361bd9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface QuickPickExpected {
acceptedItems: {
active: string[][];
selection: string[][];
dispose: boolean[];
};
}

Expand All @@ -37,8 +36,7 @@ suite('window namespace tests', function () {
selectionItems: [['zwei']],
acceptedItems: {
active: [['zwei']],
selection: [['zwei']],
dispose: [true]
selection: [['zwei']]
},
}, (err?: any) => done(err));
quickPick.items = ['eins', 'zwei', 'drei'].map(label => ({ label }));
Expand All @@ -63,8 +61,7 @@ suite('window namespace tests', function () {
selectionItems: [['zwei']],
acceptedItems: {
active: [['zwei']],
selection: [['zwei']],
dispose: [true]
selection: [['zwei']]
},
}, (err?: any) => done(err));
quickPick.items = ['eins', 'zwei', 'drei'].map(label => ({ label }));
Expand All @@ -89,8 +86,7 @@ suite('window namespace tests', function () {
selectionItems: [['eins'], ['eins', 'zwei']],
acceptedItems: {
active: [['zwei']],
selection: [['eins', 'zwei']],
dispose: [true]
selection: [['eins', 'zwei']]
},
}, (err?: any) => done(err));
quickPick.canSelectMany = true;
Expand All @@ -106,31 +102,6 @@ suite('window namespace tests', function () {
})()
.catch(err => done(err));
});

test('createQuickPick, selection events', function (_done) {
let done = (err?: any) => {
done = () => {};
_done(err);
};

const quickPick = createQuickPick({
events: ['active', 'selection', 'accept', 'selection', 'accept', 'hide'],
activeItems: [['eins']],
selectionItems: [['zwei'], ['drei']],
acceptedItems: {
active: [['eins'], ['eins']],
selection: [['zwei'], ['drei']],
dispose: [false, true]
},
}, (err?: any) => done(err));
quickPick.items = ['eins', 'zwei', 'drei'].map(label => ({ label }));
quickPick.show();

quickPick.selectedItems = [quickPick.items[1]];
setTimeout(() => {
quickPick.selectedItems = [quickPick.items[2]];
}, 0);
});
});
});

Expand Down Expand Up @@ -163,9 +134,7 @@ function createQuickPick(expected: QuickPickExpected, done: (err?: any) => void)
assert.deepEqual(quickPick.activeItems.map(item => item.label), expectedActive);
const expectedSelection = expected.acceptedItems.selection.shift();
assert.deepEqual(quickPick.selectedItems.map(item => item.label), expectedSelection);
if (expected.acceptedItems.dispose.shift()) {
quickPick.dispose();
}
quickPick.dispose();
} catch (err) {
done(err);
}
Expand Down
3 changes: 0 additions & 3 deletions src/vs/workbench/browser/parts/quickinput/quickInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,6 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
}),
this.ui.list.onDidChangeSelection(selectedItems => {
if (this.canSelectMany) {
if (selectedItems.length) {
this.ui.list.setSelectedElements([]);
}
return;
}
if (this.selectedItemsToConfirm !== this._selectedItems && equals(selectedItems, this._selectedItems, (a, b) => a === b)) {
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/browser/parts/quickinput/quickInputList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export class QuickInputList {
this._onLeave.fire();
}
}));
this.disposables.push(this.list.onSelectionChange(e => {
if (e.elements.length) {
this.list.setSelection([]);
}
}));
}

@memoize
Expand Down

0 comments on commit 7361bd9

Please sign in to comment.