👯♂️ remove asWinJSPromise #56137
This commit is contained in:
parent
cd873747c5
commit
b71ea763dc
2 changed files with 5 additions and 33 deletions
|
@ -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> {
|
export function asThenable<T>(callback: () => T | TPromise<T> | Thenable<T>): Thenable<T> {
|
||||||
return new TPromise<T>((resolve, reject) => {
|
return new TPromise<T>((resolve, reject) => {
|
||||||
let item = callback();
|
let item = callback();
|
||||||
|
|
|
@ -26,7 +26,8 @@ import { overviewRulerRangeHighlight } from 'vs/editor/common/view/editorColorRe
|
||||||
import { GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor';
|
import { GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor';
|
||||||
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { IEditorGroup } from 'vs/workbench/services/group/common/editorGroupsService';
|
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 GOTO_SYMBOL_PREFIX = '@';
|
||||||
export const SCOPE_PREFIX = ':';
|
export const SCOPE_PREFIX = ':';
|
||||||
|
@ -483,8 +484,8 @@ export class GotoSymbolHandler extends QuickOpenHandler {
|
||||||
if (this.outlineToModelCache[modelId]) {
|
if (this.outlineToModelCache[modelId]) {
|
||||||
return TPromise.as(this.outlineToModelCache[modelId]);
|
return TPromise.as(this.outlineToModelCache[modelId]);
|
||||||
}
|
}
|
||||||
|
// TODO@Ben - QuickOpenHandler#getResult should support cancellation
|
||||||
return asWinJsPromise(token => getDocumentSymbols(<ITextModel>model, token)).then(entries => {
|
return TPromise.wrap(asThenable(() => getDocumentSymbols(<ITextModel>model, CancellationToken.None)).then(entries => {
|
||||||
|
|
||||||
const model = new OutlineModel(this.toQuickOpenEntries(entries));
|
const model = new OutlineModel(this.toQuickOpenEntries(entries));
|
||||||
|
|
||||||
|
@ -492,7 +493,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
|
||||||
this.outlineToModelCache[modelId] = model;
|
this.outlineToModelCache[modelId] = model;
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue