Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copilot inline completion ignores instructions #233391

Open
CobusKruger opened this issue Nov 8, 2024 · 0 comments
Open

Copilot inline completion ignores instructions #233391

CobusKruger opened this issue Nov 8, 2024 · 0 comments
Assignees
Labels
new release Issues found in a recent release of VS Code

Comments

@CobusKruger
Copy link

Does this issue occur when all extensions are disabled?: No

  • VS Code Version: 1.95.2
  • OS Version: Windows 10 Enterprise, 19045.5011
  • Version: 1.95.2 (system setup)
    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:

  1. Add Copilot instructions to the workspace settings:
    "github.copilot.chat.codeGeneration.useInstructionFiles": true,
    "github.copilot.chat.codeGeneration.instructions": [
        {
            "file": "./copilot instructions/copilot-instructions-ts.md",
            "title": "Instructions for TypeScript code generation",
            "language": "typescript"
        }
    ]
  1. 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.

  1. 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;
}
  1. 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:

  1. I expect both use case 3 and 4 to generate code using the for-of construct, as was the case for point 3.
  2. 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.
@vs-code-engineering vs-code-engineering bot added the new release Issues found in a recent release of VS Code label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new release Issues found in a recent release of VS Code
Projects
None yet
Development

No branches or pull requests

2 participants