When you open a multi-root workspace in VS Code, GitHub Copilot must decide which files and folders to use for context. The default behavior can cause confusion because Copilot does not automatically see all folders in the workspace. This article explains exactly how Copilot handles multi-root workspaces, how to verify its behavior, and how to adjust settings so it works the way you need.
Key Takeaways: How Copilot Reacts to Multiple Root Folders
- VS Code > File > Add Folder to Workspace: Each added folder becomes a separate root. Copilot sees all open files across all roots but prioritizes the active file’s root for context.
- Copilot > Settings > GitHub Copilot: Enable or Disable per Root: You can turn Copilot off for specific root folders without affecting others.
- Workspace file (.code-workspace) > settings.json > “github.copilot.enable”: Setting this to an object with folder paths controls Copilot’s visibility per root at the workspace level.
What a Multi-Root Workspace Means for Copilot
A multi-root workspace in VS Code is a workspace that contains two or more independent folders. You create one by selecting File > Add Folder to Workspace or by opening a .code-workspace file that lists multiple paths. Each folder has its own file tree, settings, and extensions. Copilot treats the active editor’s root folder as the primary context source. It uses files open in that root for suggestions, but it can also reference files from other roots if they are open in tabs. Copilot does not merge all root folders into one virtual project. This means suggestions may be weaker if you expect Copilot to understand relationships between files in different roots.
How Copilot Selects Context
Copilot uses the currently active file’s root folder to determine which project-level context to load. For example, if you have roots named frontend and backend, and you are editing a file in frontend/src/app.js, Copilot loads context from files in frontend that you have open. It does not automatically load files from backend unless they are also open in a tab. The language server and Copilot’s analysis are scoped to the active root. This behavior is by design and matches how VS Code treats multi-root workspaces for other language features.
Prerequisites
Before you test or configure Copilot in a multi-root workspace, ensure you have the following:
- VS Code version 1.82 or later (earlier versions have limited multi-root support)
- GitHub Copilot extension version 1.150 or later
- An active GitHub Copilot subscription (Free, Pro, or Business)
- A .code-workspace file if you want to persist the multi-root configuration
How to Verify Copilot Behavior in a Multi-Root Workspace
You can check which root folder Copilot is using for context by looking at the Copilot status bar icon. The icon shows the active root folder name when you hover over it. To verify context scope, open two files from different roots, then ask Copilot for a suggestion that references a function or variable in the other root. If the suggestion is incomplete or missing, Copilot did not see that file.
- Open the Copilot status icon
Look at the bottom-right corner of VS Code. The Copilot icon shows a small folder name when you hover. This is the active root folder. - Open files from two different roots
Open one file from root A and one file from root B in separate tabs. Ensure both tabs are visible in the editor. - Ask Copilot for a cross-root suggestion
In the root A file, start typing a function name that is defined only in the root B file. If Copilot offers the completion, it has context from both open files. - Close the root B tab
Close the root B file without saving. Now ask Copilot again for the same completion. If the suggestion disappears, Copilot no longer sees that file.
Configuring Copilot Per Root Folder
You can enable or disable Copilot for specific root folders. This is useful when one root contains sensitive code or a completely different project that you do not want Copilot to analyze.
- Open the VS Code settings
Press Ctrl+Comma to open Settings. Click the Workspace tab to apply changes to the current workspace only. - Search for Copilot enable
Type “github.copilot.enable” in the search box. The setting appears as a boolean or an object depending on your VS Code version. - Set per-root values
In the settings.json file, add an object with folder paths as keys. Example:"github.copilot.enable": { "frontend": true, "backend": false }
This enables Copilot only for thefrontendroot folder. - Save the workspace file
If you use a .code-workspace file, add the same setting under thesettingsproperty. Copilot reads this setting when the workspace loads.
Common Misconceptions and Limitations
Copilot Does Not Merge Multiple Root Folders Into One Project
Some users expect Copilot to treat all root folders as a single codebase. This is not how it works. Copilot uses the active root’s language server and file index. To get cross-root suggestions, you must keep files from both roots open in tabs. There is no setting to merge roots. If you need full cross-root context, consider using a single root folder that contains all subprojects, or use symbolic links.
The .code-workspace File Must Be Saved for Per-Root Settings to Persist
If you add folders to a workspace without saving the .code-workspace file, VS Code treats the workspace as untitled. Settings you configure in the Workspace tab are lost when you close VS Code. Always save the workspace file by selecting File > Save Workspace As. Name it something meaningful like project.code-workspace.
Copilot Chat Uses the Same Root Scope
The Copilot Chat panel also scopes its context to the active root folder. When you ask a question in Chat, it only sees files from the root that contains the active editor. If you want Chat to analyze a different root, click a file in that root first. This applies to both inline chat and the sidebar chat.
Copilot in Single-Root Workspace vs Multi-Root Workspace: Key Differences
| Item | Single-Root Workspace | Multi-Root Workspace |
|---|---|---|
| Context scope | Entire root folder | Active root folder only |
| Cross-folder completions | All files in the root are available | Only open files from other roots are available |
| Per-folder enable/disable | Not applicable | Supported via github.copilot.enable object |
| Workspace settings file | Optional .code-workspace | Required for persistent per-root settings |
| Copilot Chat scope | Single root | Active root |
You now understand how GitHub Copilot behaves in a multi-root workspace. Verify the active root using the status bar icon. Keep cross-root files open if you need completions that span multiple folders. Use the github.copilot.enable setting in your .code-workspace file to turn Copilot off for specific roots. For a deeper integration, consider restructuring your project into a single root with clear subdirectories. This approach gives Copilot the broadest context and the most accurate suggestions.