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

Closed
CobusKruger opened this issue Nov 8, 2024 · 2 comments
Closed

Copilot inline completion ignores instructions #233391

CobusKruger opened this issue Nov 8, 2024 · 2 comments
Assignees
Labels
*as-designed Described behavior is as designed

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.
@hediet hediet added the *as-designed Described behavior is as designed label Dec 9, 2024
Copy link

The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines.

Happy Coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2024
@CobusKruger
Copy link
Author

@hediet As designed? I showed in some detail that the chat and inline usage yield completely different results. Are you saying that the inline usage won't be changed to use the workspace instructions, or that there is a reason for the difference?

I'm not trying to be difficult, just to understand.

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

2 participants