Fix events firing multiple times (fixes #52894)

This commit is contained in:
Christof Marti
2018-06-27 17:09:09 +02:00
parent 748d3125c1
commit 9aa90a526d
3 changed files with 79 additions and 14 deletions

View File

@@ -410,9 +410,14 @@ suite('window namespace tests', () => {
test('showQuickPick, accept second', async function () {
const resolves: ((value: string) => void)[] = [];
let done: () => void;
const unexpected = new Promise((resolve, reject) => {
done = () => resolve();
resolves.push(reject);
});
const first = new Promise(resolve => resolves.push(resolve));
const pick = window.showQuickPick(['eins', 'zwei', 'drei'], {
onDidSelectItem: item => resolves.shift()!(item as string)
onDidSelectItem: item => resolves.pop()!(item as string)
});
assert.equal(await first, 'eins');
const second = new Promise(resolve => resolves.push(resolve));
@@ -420,12 +425,19 @@ suite('window namespace tests', () => {
assert.equal(await second, 'zwei');
await commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
assert.equal(await pick, 'zwei');
done!();
return unexpected;
});
test('showQuickPick, select first two', async function () {
const resolves: ((value: string) => void)[] = [];
let done: () => void;
const unexpected = new Promise((resolve, reject) => {
done = () => resolve();
resolves.push(reject);
});
const picks = window.showQuickPick(['eins', 'zwei', 'drei'], {
onDidSelectItem: item => resolves.shift()!(item as string),
onDidSelectItem: item => resolves.pop()!(item as string),
canPickMany: true
});
const first = new Promise(resolve => resolves.push(resolve));
@@ -438,6 +450,8 @@ suite('window namespace tests', () => {
await commands.executeCommand('workbench.action.quickPickManyToggle');
await commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
assert.deepStrictEqual(await picks, ['eins', 'zwei']);
done!();
return unexpected;
});
test('showQuickPick, keep selection (Microsoft/vscode-azure-account#67)', async function () {