This commit is contained in:
Johannes Rieken
2017-03-13 13:49:15 +01:00
parent 95f4f8d03b
commit b86a54e757
3 changed files with 69 additions and 54 deletions

View File

@@ -39,53 +39,58 @@ export class ExtHostQuickOpen extends ExtHostQuickOpenShape {
ignoreFocusLost: options && options.ignoreFocusOut
});
const promise = itemsPromise.then(items => {
let pickItems: MyQuickPickItems[] = [];
for (let handle = 0; handle < items.length; handle++) {
let item = items[handle];
let label: string;
let description: string;
let detail: string;
if (typeof item === 'string') {
label = item;
} else {
label = item.label;
description = item.description;
detail = item.detail;
}
pickItems.push({
label,
description,
handle,
detail
});
}
// handle selection changes
if (options && typeof options.onDidSelectItem === 'function') {
this._onDidSelectItem = (handle) => {
options.onDidSelectItem(items[handle]);
};
}
// show items
this._proxy.$setItems(pickItems);
return quickPickWidget.then(handle => {
if (typeof handle === 'number') {
return items[handle];
}
const promise = TPromise.any(<TPromise<number | Item[]>[]>[quickPickWidget, itemsPromise]).then(values => {
if (values.key === '0') {
return undefined;
}
return itemsPromise.then(items => {
let pickItems: MyQuickPickItems[] = [];
for (let handle = 0; handle < items.length; handle++) {
let item = items[handle];
let label: string;
let description: string;
let detail: string;
if (typeof item === 'string') {
label = item;
} else {
label = item.label;
description = item.description;
detail = item.detail;
}
pickItems.push({
label,
description,
handle,
detail
});
}
// handle selection changes
if (options && typeof options.onDidSelectItem === 'function') {
this._onDidSelectItem = (handle) => {
options.onDidSelectItem(items[handle]);
};
}
// show items
this._proxy.$setItems(pickItems);
return quickPickWidget.then(handle => {
if (typeof handle === 'number') {
return items[handle];
}
return undefined;
});
}, (err) => {
this._proxy.$setError(err);
return TPromise.wrapError(err);
});
}, (err) => {
this._proxy.$setError(err);
return TPromise.wrapError(err);
});
return wireCancellationToken(token, promise, true);
}