Merge pull request #130399 from Kingwl/fix_folding_with_inlayhints

Fix folding ranges with inlay hints
This commit is contained in:
Henning Dieterichs 2021-08-11 09:35:54 +02:00 committed by GitHub
commit 37f845ee35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,13 +38,16 @@ export interface InlayHintsData {
export async function getInlayHints(model: ITextModel, ranges: Range[], token: CancellationToken): Promise<InlayHintsData[]> {
const datas: InlayHintsData[] = [];
const providers = InlayHintsProviderRegistry.ordered(model).reverse();
const promises = flatten(providers.map(provider => ranges.map(range => Promise.resolve(provider.provideInlayHints(model, range, token)).then(result => {
if (result) {
datas.push({ list: result, provider });
}
}, err => {
onUnexpectedExternalError(err);
}))));
const promises = flatten(providers.map(provider => ranges.map(range => {
return Promise.resolve(provider.provideInlayHints(model, range, token)).then(result => {
const itemsInRange = result?.filter(hint => range.containsPosition(hint.position));
if (itemsInRange?.length) {
datas.push({ list: itemsInRange, provider });
}
}, err => {
onUnexpectedExternalError(err);
});
})));
await Promise.all(promises);