You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create an instruction file with the correct name. I have this instruction in there:
When generating code iterating an array, always prefer the for-of loop over the forEach method and the normal for loop.
Find a sensible place in the code and invoke the chat interface with Ctrl+I. Provide this prompt:
Declare an array of test data containing (among other things) an amount field. Then create a loop that sums the amounts and assign it to a local variable.
Resulting code (as expected):
const testData = [
{ amount: 100 },
{ amount: 200 },
{ amount: 300 },
{ amount: 400 },
{ amount: 500 },
];
let total = 0;
for (const item of testData) {
total += item.amount;
}
In another, equally sensible place, place a comment containing the same prompt:
// Declare an array of test data containing (among other things) an amount field. Then create a loop that sums the amounts and assign it to a local variable.
Resulting code (wrong looping structure):
const testData = [
{ amount: 10 },
{ amount: 20 },
{ amount: 30 }
];
let total = 0;
for (let i = 0; i < testData.length; i++) {
total += testData[i].amount;
}
Notes:
I expect both use case 3 and 4 to generate code using the for-of construct, as was the case for point 3.
I can see that my instructions are being considered when using Ctrl+I, because it actually lists my instructions file as a reference. The same cannot be determined (due to the nature of the inline usage), but it definitely doesn't appear to do the same.
The text was updated successfully, but these errors were encountered:
Does this issue occur when all extensions are disabled?: No
Commit: e865366
Date: 2024-11-07T11:07:22.054Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045
Steps to Reproduce:
When generating code iterating an array, always prefer the
for-of
loop over theforEach
method and the normalfor
loop.Declare an array of test data containing (among other things) an amount field. Then create a loop that sums the amounts and assign it to a local variable.
Resulting code (as expected):
// Declare an array of test data containing (among other things) an amount field. Then create a loop that sums the amounts and assign it to a local variable.
Resulting code (wrong looping structure):
Notes:
The text was updated successfully, but these errors were encountered: