Codium-ai / codiumai-vscode-release

269 stars 39 forks source link

Code Suggestions offer incomplete suggestion. #122

Closed lnedry closed 12 months ago

lnedry commented 1 year ago

Request ID: 1984d836-1c8f-48d8-b06d-0440eb1eac26

One of the Code Suggestions suggests using Promise.allSettled instead of Promise.all but the suggested code is incomplete.

It creates an empty array for promises but never inserts anything into that array.

Base Code:

// line number: 974
const promises = domains.map(async (domain) => {
    // code omitted for brevity
});

await Promise.all(promises);

Suggested Code:

const promises = [];
domains.forEach(async (domain) => {
    // code omitted for brevity
});

await Promise.allSettled(promises);
almog-lv commented 1 year ago

Thanks @lnedry. @hussam789 take a look please

hussam789 commented 12 months ago

Hi @lnedry The suggestion was about:

Use `Array.prototype.forEach` and `Promise.allSettled` instead of `Array.prototype.map` and `Promise.all` to ensure all promises are settled before proceeding.

The suggestion was accompanied by a preview code to demonstrate the suggestion (high-level changes). The preview code explicitly stated that it uses an abbreviation of code blocks to shorten and simplify the preview:

//  code omitted for brevity

Once you choose this suggestion and invoke apply, you will get a diff view showing the final full implementation with before and after code for you to approve. The "unused" variable promises will be used in the full implementation.

lnedry commented 12 months ago

Thank you for the clarification!