提交 b71ea763 编写于 作者: J Johannes Rieken

:dancing_men: remove asWinJSPromise #56137

上级 cd873747
......@@ -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;
});
}));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册