👯♂️ remove asWinJSPromise #56137
This commit is contained in:
parent
cd873747c5
commit
b71ea763dc
|
@ -58,35 +58,6 @@ export function createCancelablePromise<T>(callback: (token: CancellationToken)
|
|||
};
|
||||
}
|
||||
|
||||
export function asWinJsPromise<T>(callback: (token: CancellationToken) => T | TPromise<T> | Thenable<T>): TPromise<T> {
|
||||
let source = new CancellationTokenSource();
|
||||
return new TPromise<T>((resolve, reject) => {
|
||||
let item = callback(source.token);
|
||||
if (item instanceof TPromise) {
|
||||
item.then(result => {
|
||||
source.dispose();
|
||||
resolve(result);
|
||||
}, err => {
|
||||
source.dispose();
|
||||
reject(err);
|
||||
});
|
||||
} else if (isThenable<T>(item)) {
|
||||
item.then(result => {
|
||||
source.dispose();
|
||||
resolve(result);
|
||||
}, err => {
|
||||
source.dispose();
|
||||
reject(err);
|
||||
});
|
||||
} else {
|
||||
source.dispose();
|
||||
resolve(item);
|
||||
}
|
||||
}, () => {
|
||||
source.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
export function asThenable<T>(callback: () => T | TPromise<T> | Thenable<T>): Thenable<T> {
|
||||
return new TPromise<T>((resolve, reject) => {
|
||||
let item = callback();
|
||||
|
|
|
@ -26,7 +26,8 @@ import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRe
|
|||
import { GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export const GOTO_SYMBOL_PREFIX = '@';
|
||||
export const SCOPE_PREFIX = ':';
|
||||
|
@ -483,8 +484,8 @@ export class GotoSymbolHandler extends QuickOpenHandler {
|
|||
if (this.outlineToModelCache[modelId]) {
|
||||
return TPromise.as(this.outlineToModelCache[modelId]);
|
||||
}
|
||||
|
||||
return asWinJsPromise(token => getDocumentSymbols(<ITextModel>model, token)).then(entries => {
|
||||
// TODO@Ben - QuickOpenHandler#getResult should support cancellation
|
||||
return TPromise.wrap(asThenable(() => getDocumentSymbols(<ITextModel>model, CancellationToken.None)).then(entries => {
|
||||
|
||||
const model = new OutlineModel(this.toQuickOpenEntries(entries));
|
||||
|
||||
|
@ -492,7 +493,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
|
|||
this.outlineToModelCache[modelId] = model;
|
||||
|
||||
return model;
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue