When you accept a code suggestion from GitHub Copilot in VS Code, you might need to know where that suggestion came from. Copilot can generate code based on either the public code it was trained on or the context of your current file. Without this information, you risk using code that may have a license restriction or that was pulled from a similar project you did not intend to reference. This article explains how to view the source of a Copilot suggestion, why the source matters, and what to do when the source is not displayed correctly.
Key Takeaways: Viewing Copilot Suggestion Source in VS Code
- VS Code status bar icon > Copilot suggestion source indicator: Shows whether a suggestion came from public code, your current file, or a matched local file.
- Ctrl+Shift+I (Windows/Linux) or Cmd+Shift+I (Mac): Opens the Copilot suggestion source dialog for the last accepted suggestion.
- Copilot: Show Suggestion Source command: Opens the same dialog from the Command Palette when you need to check a specific suggestion.
Why Copilot Suggestion Source Matters
GitHub Copilot uses a large language model trained on billions of lines of public code. When you accept a suggestion, Copilot may have matched your request to a specific snippet from its training data. The source can be one of three types:
- Public code: The suggestion matches code from public repositories on GitHub. This code may carry open-source licenses.
- Your current file: The suggestion is generated based on patterns in the file you are editing.
- Matched local file: The suggestion matches code from another file in your workspace.
Knowing the source helps you decide whether you need to check the original license, attribute the code, or replace the suggestion with your own implementation. This is especially important in commercial projects where license compliance is required.
How to View the Suggestion Source in VS Code
Follow these steps to view the source of a Copilot suggestion after you accept it.
- Accept a Copilot suggestion
Type code in a file and press Tab when Copilot shows a ghost text suggestion. The suggestion is now inserted into your file. - Open the suggestion source dialog
Press Ctrl+Shift+I on Windows or Linux, or Cmd+Shift+I on Mac. A small dialog appears showing the source type and, if applicable, the repository URL or file path. - Review the source details
If the source is labeled Public code, the dialog shows the repository name, the file path, and the license type. If the source is Your current file or Matched local file, the dialog shows the file name and line number. - Open the source file (optional)
Click the link in the dialog to open the original file in a new VS Code tab. This lets you inspect the exact code that Copilot matched.
You can also use the Command Palette to view the source. Press Ctrl+Shift+P or Cmd+Shift+P, type Copilot: Show Suggestion Source, and press Enter. This command shows the same dialog for the last accepted suggestion.
When the Suggestion Source Is Not Available
In some cases, the suggestion source dialog may show No source available. This happens when:
- Copilot generated the suggestion from its model without matching any specific training snippet.
- You have not accepted a suggestion in the current session.
- The Copilot extension is not enabled for the current file type.
To resolve this, ensure you have accepted at least one suggestion in the current file. If the source still does not appear, check that the Copilot extension is active by looking for the Copilot icon in the VS Code status bar. If the icon is gray, the extension is disabled. Open the Extensions view, find GitHub Copilot, and click Enable.
Common Issues When Viewing Suggestion Source
Copilot Shows Incorrect Source for a Suggestion
Sometimes the source dialog displays a public repository that does not match the code you expected. This can happen if Copilot matched a different part of the code. To verify, open the source file from the dialog and compare the code. If the match is incorrect, you can ignore the source or use the Copilot: Discard Suggestion command to remove the inserted code and generate a new suggestion.
Copilot Does Not Show the Source Dialog
If pressing Ctrl+Shift+I or Cmd+Shift+I does nothing, check that the keyboard shortcut is not overridden by another extension. Open the Keyboard Shortcuts editor, search for Copilot: Show Suggestion Source, and see if the key binding is set. If it is missing, add it manually by clicking the plus icon and pressing the key combination.
Copilot Suggestion Source Shows Public Code but No License
Some public repositories do not include a license file. In this case, the dialog shows No license. Without a license, the code is copyrighted by default, and you should not use it without permission. Replace the suggestion with your own implementation or consult your legal team.
Copilot Suggestion Source vs Copilot Chat Source: Key Differences
| Item | Copilot Suggestion Source | Copilot Chat Source |
|---|---|---|
| Trigger | After accepting a ghost text suggestion | After receiving a response in the Chat panel |
| Keyboard shortcut | Ctrl+Shift+I or Cmd+Shift+I | No dedicated shortcut; use Command Palette |
| Information shown | Source type, repository URL, file path, license | Source type only (public code or your code) |
| Use case | Check license and attribution for inline code | Check source of code snippets in chat replies |
Copilot Chat shows a source badge next to code blocks in the chat response. Click the badge to see the repository URL and license. This is useful when you ask Copilot Chat to generate code and want to verify its origin before copying it into your project.
Conclusion
You can now view the source of any Copilot suggestion in VS Code using the Ctrl+Shift+I or Cmd+Shift+I shortcut. Check the source dialog after every accepted suggestion to ensure you comply with open-source licenses. If the source shows a public repository without a license, replace the code with your own implementation. For Copilot Chat responses, click the source badge to see the repository details. This practice keeps your codebase legally safe and helps you understand where Copilot is drawing its knowledge.