GitHub Copilot does not read your entire multi-gigabyte repository on every keystroke. Believing that it does is the single fastest way to get frustrated with hallucinated imports and broken method signatures.
At 365Finds, we look at developer tools through the lens of engineering trade-offs. Real-time code completion has an unforgiving latency budget: roughly 100 to 300 milliseconds. An LLM cannot execute deep vector searches across tens of thousands of workspace files within that window. Instead, VS Code and GitHub Copilot split context construction into two distinct operational tiers: a high-speed heuristic pipeline for inline "ghost text" completions, and a background semantic indexing engine for agentic workflows like @workspace and multi-file edits.
Once you understand where the boundary sits between these two systems, Copilot transforms from an unpredictable guesser into a sharp, reliable pair programmer.
The Dual-Engine Architecture: Speed vs. Depth
The core challenge of cross-file code suggestion is context budgeting. Large language models operate on finite token windows. Cramming arbitrary project files into a prompt dilutes attention and inflates response latency to unusable levels. GitHub Copilot solves this by bifurcating how it gathers context:
| Mechanism | Primary Objective | Retrieval Target | Latency Profile | Core Techniques |
|---|---|---|---|---|
| Neighboring Tabs (Inline Completions) | Real-time typing suggestions | Currently open & recent editor tabs | 100–300 ms | Jaccard similarity; 60-line sliding windows; Fill-In-the-Middle (FIM) |
| Semantic Workspace Indexing (Chat & Edits) | Project-wide refactoring & queries | Entire indexed workspace directory | 1–5+ seconds | Local vector embeddings; Language Server Protocol (LSP); AST symbol trees; Grep search |
At 365Finds, our testing shows that most developer dissatisfaction stems from expecting inline completions to pull from unindexed, closed files tucked three directories deep. Inline completion relies almost entirely on your open editor tabs.
1. How Inline Completions Handle Cross-File Context: The "Neighboring Tabs" Engine
When you pause typing in VS Code, GitHub Copilot constructs a prompt on the fly. To make inline suggestions aware of types or helpers in other files without stalling your cursor, it uses an algorithm known internally as Neighboring Tabs.
[ Active File Cursor ]
|
+---> Extracts prefix & suffix (Fill-In-the-Middle)
|
+---> Scans open editor tabs in VS Code
| |
| +---> Chunks tabs into ~60-line sliding windows
| +---> Measures token overlap via Jaccard similarity
| +---> Discards redundant boilerplate
| +---> Selects top N highest-relevance snippets
|
v
[ Final Assembled Prompt to LLM ]
The Step-by-Step Inline Pipeline
- Sliding Window Chunking: Copilot does not ingest your neighboring open files whole. It divides each open tab into manageable chunks, typically sliding windows around 60 lines long.
- Jaccard Similarity Scoring: To figure out which chunks from neighboring tabs actually matter to the code under your cursor, Copilot calculates the Jaccard similarity coefficient between the tokens in the active buffer and the candidate chunks: $$J(A, B) = \frac{|A \cap B|}{|A \cup B|}$$ This measures token overlap—matching variable names, imported class names, schema fields, and language keywords.
- Redundancy Pruning: If you have three similar test files or duplicate boilerplate open, Jaccard scoring deduplicates the candidates. The prompt budget is preserved for distinct, high-signal tokens.
- Fill-In-the-Middle (FIM) Assembly: Copilot anchors the prompt with your cursor's prefix (code before) and suffix (code after), then injects the winning snippets from neighboring tabs as contextual comments or reference blocks.
According to GitHub's engineering measurements, combining neighboring tabs with FIM produced roughly a 10% relative increase in accepted completions without degrading typing latency.
2. How Copilot Chat and Edits Build Full Workspace Context
When you switch to Copilot Chat, invoke the @workspace participant, or use multi-file editing features, the 200-millisecond latency restriction disappears. Copilot can now afford comprehensive workspace retrieval.
Local Semantic Embeddings
VS Code maintains a local semantic index of your project files inside the application's workspaceStorage directory.
- Files are parsed, split into structural units (functions, classes, blocks), and transformed into vector embeddings.
- When you issue a prompt or reference
#codebase, Copilot performs vector similarity searches to locate code that matches your conceptual intent—even when the naming does not match your exact keywords.
Language Intelligence and LSP
Semantic search alone can be brittle when tracking precise call chains. Copilot supplements vector search with VS Code's native Language Server Protocol (LSP) and Tree-sitter AST queries:
- Symbol Definitions & Usages: Traces where an interface is defined, what implements it, and where a specific method is called across files.
- Exact Grep Search: Catches raw error strings, environment variable keys, or config parameters that embeddings often overlook.
Respecting Boundaries
The workspace indexer is strictly scoped. It automatically respects .gitignore rules, files.exclude workspace settings, and enterprise content exclusion policies (.copilotignore). If a file is excluded by Git or admin policy, Copilot never indexes it or submits its tokens to the underlying model.
How to Maximize GitHub Copilot's Cross-File Accuracy: A Practical Workflow
Understanding this architecture leads to four immediate habits that dramatically improve Copilot's suggestions in VS Code:
1. Curate Your "Working Set" in Open Tabs
Because inline ghost text looks primarily at neighboring tabs, keep your target data models, interface definitions, or utility libraries open in adjacent VS Code editor tabs while coding. If you are writing a React component that consumes a specific TypeScript type, opening types.ts in a background tab instantly bridges the context gap.
2. Anchor Architecture in .github/copilot-instructions.md
Do not repeat project conventions in every chat prompt. Place repository-wide design standards, preferred libraries, and pattern constraints in .github/copilot-instructions.md. Copilot automatically incorporates these instructions as persistent cross-file guardrails across both inline context and chat.
3. Explicitly Direct Context with #file and #codebase
If Copilot Chat misses an architectural dependency, stop asking it to guess. Use explicit context variables:
- Use
#file:src/services/api.tsto pin an exact reference file into the prompt. - Use
#codebaseor@workspacewhen you need global semantic discovery across unvisited directories.
4. Rebuild the Index When Refactoring Large Trees
If you perform extensive renames or merge major branch updates, local semantic caches can briefly fall out of sync. Open the VS Code Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and execute GitHub Copilot: Build Codebase Semantic Index to force an immediate refresh.
365Finds Verdict
At 365Finds, we admire GitHub Copilot's engineering pragmatism. Splitting context retrieval between a fast Jaccard-based tab analyzer for inline completions and a deep semantic embedding engine for workspace chat is a masterclass in latency engineering.
However, Copilot's marketing often obscures this distinction, leading developers to assume the engine possesses omnipresent repository awareness at every keystroke. It does not. The moment you treat open tabs as an active working memory and utilize explicit # mentions for broader queries, Copilot stops hallucinating and begins delivering code that genuinely fits your architecture.