5.1.2. How Copilot Determines Context
💡 First Principle: Copilot builds context mostly from your editor state, not just your typed words. The files you have open, the code around your cursor, and your selection are all inputs — so "crafting context" is as much about what you expose as what you type.
Recall from Phase 4 that input processing assembles a prompt from several signals. For prompting, the practical levers are:
- Open files and neighboring tabs — Copilot draws on what's open, so opening relevant files (and closing irrelevant ones) shapes the context.
- The active selection / cursor location — code around your cursor and any highlighted selection weigh heavily.
- Comments and Chat messages — your explicit instructions.
- File path and language — hints about what kind of code is expected.
- Custom/instructions files — repository conventions Copilot should follow (Phase 2).
A scenario: a developer gets generic suggestions because the relevant model and helper files are closed. Opening them — or selecting the related code — gives Copilot the context to produce specific, fitting suggestions. The fix was context, not a different model.
💡 Key Point: You steer context by managing your workspace, not only by typing. Open what's relevant; highlight the code you're working against.
⚠️ Exam Trap: "Context is only what you type into Chat" is false. Copilot determines context substantially from your open files, selection, and workspace state.
Reflection Question: A developer complains Copilot's suggestions ignore a helper function they wrote. Assuming the prompt text is fine, what's the most likely context fix?